{
  "cells": [
    {
      "attachments": {},
      "cell_type": "markdown",
      "metadata": {
        "id": "TXC2wBpCU9f7"
      },
      "source": [
        "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/pinecone-io/examples/blob/master/docs/langchain-retrieval-agent.ipynb) [![Open nbviewer](https://raw.githubusercontent.com/pinecone-io/examples/master/assets/nbviewer-shield.svg)](https://nbviewer.org/github/pinecone-io/examples/blob/master/docs/langchain-retrieval-agent.ipynb)"
      ]
    },
    {
      "attachments": {},
      "cell_type": "markdown",
      "metadata": {
        "id": "bhWwrfbbVGOA"
      },
      "source": [
        "\n",
        "# Retrieval Agents with Pinecone Assistant, LangChain and LangGraph\n",
        "\n",
        "We've seen in previous chapters how powerful [retrieval augmentation](https://www.pinecone.io/learn/series/langchain/langchain-retrieval-augmentation/) and [conversational agents](https://www.pinecone.io/learn/series/langchain/langchain-agents/) can be. They become even more impressive when we begin using them together.\n",
        "\n",
        "Conversational agents can struggle with data freshness, knowledge about specific domains, or accessing internal documentation. By coupling agents with retrieval augmentation tools we no longer have these problems.\n",
        "\n",
        "In this notebook we'll learn how to do this using Pinecone Assistant's Context API, LangGraph, and OpenAI.\n",
        "\n",
        "Specifically, we'll learn how to:\n",
        "\n",
        "1. Upload PDFs to Pinecone Assistant, to instantly create an agentic RAG Chatbot\n",
        "2. Retrieve the context that the Pinecone Assistant uses for our own agentic application\n",
        "3. Incorporate OpenAI calls and LangGraph orchestration to build a simple study guide builder\n",
        "4. Run our application and improve it!\n",
        "\n",
        "Let's begin!\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Prerequisites\n",
        "\n",
        "To begin, we must install several libraries that we will be using in this notebook."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 105,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "pva9ehKXUpU2",
        "outputId": "d74ebf63-a115-48fb-f950-71d8150a691c"
      },
      "outputs": [],
      "source": [
        "!pip install -qU \\\n",
        "  pinecone==7.0.2 \\\n",
        "  pinecone-notebooks==0.1.1 \\\n",
        "  langchain==0.3.26\\\n",
        "  langchain-openai==0.3.25\\\n",
        "  langchain-pinecone==0.2.8\\\n",
        "  langgraph==0.3.14 \\\n",
        "  tqdm==4.67.1\\\n",
        "  pinecone-plugin-assistant==1.7.0"
      ]
    },
    {
      "attachments": {},
      "cell_type": "markdown",
      "metadata": {
        "id": "ZTgrOQziXUto"
      },
      "source": [
        "## Setting up Pinecone Assistant"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 106,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 250
        },
        "id": "laSDMjqQXuj-",
        "outputId": "2a05a716-73db-4da4-e19b-4378290ef2a9"
      },
      "outputs": [],
      "source": [
        "import os\n",
        "from getpass import getpass\n",
        "\n",
        "def get_pinecone_api_key():\n",
        "    \"\"\"\n",
        "    Get Pinecone API key from environment variable or prompt user for input.\n",
        "    Returns the API key as a string.\n",
        "\n",
        "    Only necessary for notebooks. When using Pinecone yourself, \n",
        "    you can use environment variables or the like to set your API key.\n",
        "    \"\"\"\n",
        "    api_key = os.environ.get(\"PINECONE_API_KEY\")\n",
        "    \n",
        "    if api_key is None:\n",
        "        try:\n",
        "            # Try Colab authentication if available\n",
        "            from pinecone_notebooks.colab import Authenticate\n",
        "            Authenticate()\n",
        "            # If successful, key will now be in environment\n",
        "            api_key = os.environ.get(\"PINECONE_API_KEY\")\n",
        "        except ImportError:\n",
        "            # If not in Colab or authentication fails, prompt user for API key\n",
        "            print(\"Pinecone API key not found in environment.\")\n",
        "            api_key = getpass(\"Please enter your Pinecone API key: \")\n",
        "            # Save to environment for future use in session\n",
        "            os.environ[\"PINECONE_API_KEY\"] = api_key\n",
        "    \n",
        "    return api_key\n",
        "\n",
        "api_key = get_pinecone_api_key()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 107,
      "metadata": {},
      "outputs": [],
      "source": [
        "from pinecone import Pinecone\n",
        "\n",
        "pc = Pinecone(\n",
        "    # source_tag isn't necessary for production workloads, so feel free to remove later\n",
        "    source_tag=\"pinecone_examples:docs:langchain_retrieval_agent\",\n",
        "    api_key=api_key)\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Creating our assistant\n",
        "\n",
        "To create an assistant, simply pass a name, some instructions, and a region."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 134,
      "metadata": {},
      "outputs": [],
      "source": [
        "assistant_list = pc.assistant.list_assistants()\n",
        "\n",
        "\n",
        "assistant_exists = True if \"textbook-assistant\" in [assistant.name for assistant in assistant_list] else False\n",
        "\n",
        "if not assistant_exists:\n",
        "    assistant = pc.assistant.create_assistant(\n",
        "        assistant_name=\"textbook-assistant\", \n",
        "        instructions=\"Help answer questions about provided textbooks with aim toward creating study guides and grounded learning materials\", # Description or directive for the assistant to apply to all responses.\n",
        "        region=\"us\", # Region to deploy assistant. Options: \"us\" (default) or \"eu\".\n",
        "        timeout=30 # Maximum seconds to wait for assistant status to become \"Ready\" before timing out.\n",
        "        \n",
        "    )\n",
        "\n",
        "assistant = pc.assistant.Assistant(\n",
        "    assistant_name=\"textbook-assistant\", \n",
        ")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Uploading our data\n",
        "\n",
        "We'll upload a massive 1000 page textbook to our assistant to showcase how easy it is to get started with it. The textbook we use here for demo purposes is a freely available textbook, Introduction to Computer Science, made available by OpenStax [online here](https://openstax.org/details/books/introduction-computer-science).\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 109,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Download our textbook, thank you Openstax!\n",
        "\n",
        "url = \"https://assets.openstax.org/oscms-prodcms/media/documents/Introduction_To_Computer_Science_-_WEB.pdf\"\n",
        "\n",
        "\n",
        "import requests\n",
        "\n",
        "response = requests.get(url)\n",
        "\n",
        "with open(\"textbook.pdf\", \"wb\") as f:\n",
        "    f.write(response.content)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Uploading PDF to our Assistant\n",
        "\n",
        "The Assistant takes care of preprocessing and chunking, embedding and upserting our PDF, which allows us to focus on building our agentic application. \n",
        "\n",
        "All we need to do here is upload our file! It'll take some time do to all the operations involved."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 110,
      "metadata": {},
      "outputs": [
        {
          "data": {
            "text/plain": [
              "[FileModel(name='textbook.pdf', id='752a66de-dfd0-4036-a2c0-10c97ae1931d', metadata=None, created_on='2025-06-26T21:10:58.578812211Z', updated_on='2025-06-26T21:12:34.118317190Z', status='Available', percent_done=1.0, signed_url=None, error_message=None, size=53398130.0),\n",
              " FileModel(name='textbook.pdf', id='cb3503fa-c29e-4733-82a3-cbe1ee5f5fd7', metadata=None, created_on='2025-06-25T20:17:02.918853640Z', updated_on='2025-06-25T20:18:26.259303330Z', status='Available', percent_done=1.0, signed_url=None, error_message=None, size=53398130.0),\n",
              " FileModel(name='textbook.pdf', id='e33526ed-1e5c-4263-9cc0-b225ec93c734', metadata=None, created_on='2025-06-16T20:09:50.703258033Z', updated_on='2025-06-16T20:11:32.980858639Z', status='Available', percent_done=1.0, signed_url=None, error_message=None, size=53398130.0)]"
            ]
          },
          "execution_count": 110,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "\n",
        "# Upload a file. Will take about three minutes to process\n",
        "\n",
        "response = assistant.upload_file(\n",
        "        file_path=\"textbook.pdf\",\n",
        "        timeout=None\n",
        "    )\n",
        "\n",
        "\n",
        "assistant.list_files()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Querying our Assistant\n",
        "\n",
        "Now that the pdf is ready, and the assistant is loaded, we can send messages to it!\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 111,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Let's try querying it!\n",
        "from pinecone_plugins.assistant.models.chat import Message\n",
        "\n",
        "\n",
        "assistant = pc.assistant.Assistant(\n",
        "    assistant_name=\"textbook-assistant\", \n",
        ")\n",
        "\n",
        "\n",
        "msg = Message(role=\"user\", content=\"Can you teach me about how algorithms work?\")\n",
        "\n",
        "# The highlights parameter allows us to get in-line citations in our responses. Handy for fact-checking!\n",
        "resp = assistant.chat(messages=[msg], include_highlights=True, model=\"claude-3-7-sonnet\")\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 112,
      "metadata": {},
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "# Understanding Algorithms\n",
            "\n",
            "## What is an Algorithm?\n",
            "\n",
            "An algorithm is a sequence of precise instructions that takes any input and computes the corresponding output. It's essentially a step-by-step procedure that must be followed in a specific order to solve a problem. Computer programs typically execute algorithms to perform certain tasks.\n",
            "\n",
            "## Key Characteristics of Algorithms\n",
            "\n",
            "For an algorithm to be effective, it must have several key characteristics:\n",
            "\n",
            "1. **Unambiguous**: Each step of the algorithm must be very well defined and precise.\n",
            "\n",
            "2. **Deterministic**: The algorithm must be reproducible and repeatable so that the same set of inputs produce the same output.\n",
            "\n",
            "3. **Efficient**: The algorithm must consume a reasonable amount of time and storage based on the problem needs. An algorithm can be finite and precise, but if it requires 100 years to generate a result, it is clearly useless.\n",
            "\n",
            "## Historical Context\n",
            "\n",
            "The concept of an algorithm was invented thousands of years ago alongside early number systems. Algorithms use inputs and a finite number of steps to carry out arithmetic operations like addition, subtraction, multiplication, and division, and produce outputs used in computing. Today's computers still rely on the same foundations of numbers, calculations, and algorithms, except at the scale of billions of numbers and billions of calculations per second.\n",
            "\n",
            "## Algorithmic Problem-Solving\n",
            "\n",
            "Algorithmic problem-solving refers to a particular set of approaches and methods for designing algorithms that draws on computing's historical connections to the study of mathematical problem solving. Early computer scientists were influenced by mathematical formalism and mathematical problem solving.\n",
            "\n",
            "The goal of algorithmic problem-solving is to find an \"efficient\" solution, either in terms of execution time (e.g., number of computer instructions) or space used (e.g., computer memory size). The study emphasizes the formal problem or task, with specific input data and output data corresponding to each input.\n",
            "\n",
            "## Types of Algorithms\n",
            "\n",
            "There are several categories of computational problems that algorithms address:\n",
            "\n",
            "### 1. Data Structure Problems\n",
            "These involve the storage and retrieval of elements for implementing abstract data types such as lists, sets, maps, and priority queues. Examples include:\n",
            "- **Searching**: Retrieving a target element from a collection of elements\n",
            "- **Sorting**: Rearranging elements into a logical order\n",
            "- **Hashing**: Assigning a meaningful integer index for each object\n",
            "\n",
            "### 2. Graph Problems\n",
            "These involve graphs that represent relationships between data. Examples include:\n",
            "- **Traversal**: Exploring all the vertices in a graph\n",
            "- **Minimum spanning tree**: Finding a lowest-cost way to connect all the vertices to each other\n",
            "- **Shortest path**: Finding the lowest-cost way to get from one vertex to another\n",
            "\n",
            "### 3. String Problems\n",
            "These involve text or information represented as a sequence of characters. Examples include:\n",
            "- **Matching**: Searching for a text pattern within a document\n",
            "- **Compression**: Representing information using less data storage\n",
            "- **Cryptography**: Masking or obfuscating text to make it unintelligible\n",
            "\n",
            "## Algorithm Execution Models\n",
            "\n",
            "Various patterns of execution models may be used to step through the instructions provided in an algorithm:\n",
            "\n",
            "1. **Sequential Execution**: The traditional step-by-step execution model\n",
            "\n",
            "2. **Parallel/Concurrent Execution**: Used to optimize algorithm execution efficiency. For example, if you and a friend are buying tickets for a movie and there are three independent lines, you may opt for a parallel processing model by having you and your friend join two separate lines.\n",
            "\n",
            "3. **Recursion**: A problem-solving technique where a process calls itself to solve smaller instances of the same problem. It allows for elegant solutions to complex problems by breaking them down into smaller, more manageable parts.\n",
            "\n",
            "## Representing Algorithms\n",
            "\n",
            "Algorithms are most commonly written as either pseudocode or a flowchart:\n",
            "\n",
            "- **Pseudocode**: An outline of the logic of algorithms using a combination of language and high-level programming concepts. Each step is shown in a clearly ordered, written structure.\n",
            "\n",
            "- **Flowchart**: Clearly shows the flow and direction of decisions in a visual way using a diagram.\n",
            "\n",
            "By understanding these fundamental concepts, you can begin to appreciate how algorithms form the foundation of modern computing and problem-solving.\n"
          ]
        }
      ],
      "source": [
        "print(resp[\"message\"][\"content\"])"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 113,
      "metadata": {},
      "outputs": [
        {
          "data": {
            "text/plain": [
              "[{'position': 163,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211316Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=3aa5fd4997951b1b659da3788422ce13fe8900d346c2730cd7523438bbd18f695dc0062f3a00fce52d5864e1f407d6bde9a96f330602b2cc33f8fc7495148f0c68abcc9401afa7e9cd2c4a8d50cb1d17d7f0df7979111e72538236110f24cb5d04604bb6774c0d3ea2900d39db13e113bdd0f0fe452677d0730716a041c75856064c9b48a7644ff92cbd54692e5f9cf09798d81ae0c6cc60ac377113f8f0e3fc4e3c3bea676c1d3deeb1dc9e8adfc4522a341668b13d56aaec2b4c7f02b1e84fbdb2ff10bd36bdbb4b297d6a1c6942454e5f1122889308bc87e0a03f97357f9b1ba8fc593d10be3f7631ef93c7de9df2618326647dcc36fadc07aa8309328f50',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [56, 57, 58],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'These steps can be added as actions in the table previously shown and expressed as steps in the pseudocode\\r\\nusing programming keywords such as INPUT, OUTPUT, IF, THEN, ELSE, and START. The corresponding'}}]},\n",
              " {'position': 267,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [56, 57, 58],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'An algorithm is a sequence of steps/instructions that must be followed in a specific order to solve a problem.\\r\\nAlgorithms make it possible to describe a solution to a problem by writing down the instructions that are'}}]},\n",
              " {'position': 340,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [56, 57, 58],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'combination of language and high-level programming concepts is called pseudocode. Each step is shown in a\\r\\nclearly ordered, written structure. A flowchart clearly shows the flow and direction of decisions in a visual way'}}]},\n",
              " {'position': 542,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [210, 211, 212],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'The first characteristic is that an algorithm must be unambiguous. Each step of the algorithm must be very\\r\\nwell defined and precise. The second characteristic is that the algorithm must be deterministic to be'}}]},\n",
              " {'position': 671,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [210, 211, 212],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'well defined and precise. The second characteristic is that the algorithm must be deterministic to be\\r\\nreproducible and repeatable so that the same set of inputs produce the same output. The third characteristic'}}]},\n",
              " {'position': 785,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [210, 211, 212],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'reproducible and repeatable so that the same set of inputs produce the same output. The third characteristic\\r\\nis that the algorithm, when implemented on a computer, must consume a reasonable amount of time and\\r\\nstorage based on the problem needs. For example, an algorithm can be finite and precise, but if it requires 100'}}]},\n",
              " {'position': 899,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [210, 211, 212],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'storage based on the problem needs. For example, an algorithm can be finite and precise, but if it requires 100\\r\\nyears to generate a result, it is clearly useless. For instance, an algorithm that counts the number of even'}}]},\n",
              " {'position': 1019,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [20, 21, 22],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'systems such as the Arabic number system (0, 1, 2, 3, . . .), which included zero and place values that cannot be\\r\\ncomputed with abaci. The concept of an algorithm was also invented around this time. Algorithms use inputs'}}]},\n",
              " {'position': 1202,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [20, 21, 22],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'computed with abaci. The concept of an algorithm was also invented around this time. Algorithms use inputs\\r\\nand a finite number of steps to carry out arithmetic operations like addition, subtraction, multiplication, and'}}]},\n",
              " {'position': 1381,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [20, 21, 22],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'division, and produce outputs used in computing. Today’s computers still rely on the same foundations of\\r\\nnumbers, calculations, and algorithms, except at the scale of billions of numbers and billions of calculations\\r\\nper second.'}}]},\n",
              " {'position': 1615,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': 'e33526ed-1e5c-4263-9cc0-b225ec93c734',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-16T20:09:50.703258033Z',\n",
              "     'updated_on': '2025-06-16T20:11:32.980858639Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2Fe33526ed-1e5c-4263-9cc0-b225ec93c734.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=8890bd0c766f4fc2a85f3776eae7e5be33fad03faeaedd43b04c1d21ec60458a203b2a66bf9240eee6533f042203035916f57dd363bfee3f37016e774d9fd7d95e064833584137cbf189670b3c5c15a9cc7d5c2a43c1545587e34dc7530d4722b15a08409d29676c0270e968147ffd5ad9314385786c29d59dcf0eda14395bfb6dd904cbfe7dbedf0c55d3072ec1a75405f36ced74dd9c6aff65d08ba8cd9b3233c683c58674c5dd960110debfcb2ae148855b4b36b96113877b9ba5a111f08c14aa7bfc305e53eaa2e436f38bba47e00c99d5ef850cf027516343457fecc93ef922de818d6bf4a45deec8c217e220bea56c438c55b48d71ff01a908950edfdf',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [109, 110, 111],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'output, while algorithmic problem-solvingrefers to a particular set of approaches and methods for\\ndesigning algorithms that draws on computing’s historical connections to the study of mathematical problem\\nsolving. Early computer scientists were influenced by mathematical formalism and mathematical problem'}}]},\n",
              " {'position': 1717,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': 'e33526ed-1e5c-4263-9cc0-b225ec93c734',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-16T20:09:50.703258033Z',\n",
              "     'updated_on': '2025-06-16T20:11:32.980858639Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2Fe33526ed-1e5c-4263-9cc0-b225ec93c734.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=8890bd0c766f4fc2a85f3776eae7e5be33fad03faeaedd43b04c1d21ec60458a203b2a66bf9240eee6533f042203035916f57dd363bfee3f37016e774d9fd7d95e064833584137cbf189670b3c5c15a9cc7d5c2a43c1545587e34dc7530d4722b15a08409d29676c0270e968147ffd5ad9314385786c29d59dcf0eda14395bfb6dd904cbfe7dbedf0c55d3072ec1a75405f36ced74dd9c6aff65d08ba8cd9b3233c683c58674c5dd960110debfcb2ae148855b4b36b96113877b9ba5a111f08c14aa7bfc305e53eaa2e436f38bba47e00c99d5ef850cf027516343457fecc93ef922de818d6bf4a45deec8c217e220bea56c438c55b48d71ff01a908950edfdf',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [109, 110, 111],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'solving. Early computer scientists were influenced by mathematical formalism and mathematical problem\\nsolving. George Pólya’s 1945 book, How to Solve It, outlines a process for solving problems that begins with a'}}]},\n",
              " {'position': 1912,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': 'e33526ed-1e5c-4263-9cc0-b225ec93c734',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-16T20:09:50.703258033Z',\n",
              "     'updated_on': '2025-06-16T20:11:32.980858639Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2Fe33526ed-1e5c-4263-9cc0-b225ec93c734.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=8890bd0c766f4fc2a85f3776eae7e5be33fad03faeaedd43b04c1d21ec60458a203b2a66bf9240eee6533f042203035916f57dd363bfee3f37016e774d9fd7d95e064833584137cbf189670b3c5c15a9cc7d5c2a43c1545587e34dc7530d4722b15a08409d29676c0270e968147ffd5ad9314385786c29d59dcf0eda14395bfb6dd904cbfe7dbedf0c55d3072ec1a75405f36ced74dd9c6aff65d08ba8cd9b3233c683c58674c5dd960110debfcb2ae148855b4b36b96113877b9ba5a111f08c14aa7bfc305e53eaa2e436f38bba47e00c99d5ef850cf027516343457fecc93ef922de818d6bf4a45deec8c217e220bea56c438c55b48d71ff01a908950edfdf',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [109, 110, 111],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'Therefore, the goal of algorithmic problem-solving, as opposed to mathematical problem solving, is to find an\\n“efficient” solution, either in terms of execution time (e.g., number of computer instructions) or space used\\n(e.g., computer memory size). Consequently, the study of algorithmic problem-solving emphasizes the formal'}}]},\n",
              " {'position': 2031,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': 'e33526ed-1e5c-4263-9cc0-b225ec93c734',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-16T20:09:50.703258033Z',\n",
              "     'updated_on': '2025-06-16T20:11:32.980858639Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2Fe33526ed-1e5c-4263-9cc0-b225ec93c734.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=8890bd0c766f4fc2a85f3776eae7e5be33fad03faeaedd43b04c1d21ec60458a203b2a66bf9240eee6533f042203035916f57dd363bfee3f37016e774d9fd7d95e064833584137cbf189670b3c5c15a9cc7d5c2a43c1545587e34dc7530d4722b15a08409d29676c0270e968147ffd5ad9314385786c29d59dcf0eda14395bfb6dd904cbfe7dbedf0c55d3072ec1a75405f36ced74dd9c6aff65d08ba8cd9b3233c683c58674c5dd960110debfcb2ae148855b4b36b96113877b9ba5a111f08c14aa7bfc305e53eaa2e436f38bba47e00c99d5ef850cf027516343457fecc93ef922de818d6bf4a45deec8c217e220bea56c438c55b48d71ff01a908950edfdf',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [109, 110, 111],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': '(e.g., computer memory size). Consequently, the study of algorithmic problem-solving emphasizes the formal\\nproblemor task, with specific input data and output data corresponding to each input. There are many other'}}]},\n",
              " {'position': 2305,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': 'e33526ed-1e5c-4263-9cc0-b225ec93c734',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-16T20:09:50.703258033Z',\n",
              "     'updated_on': '2025-06-16T20:11:32.980858639Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2Fe33526ed-1e5c-4263-9cc0-b225ec93c734.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=8890bd0c766f4fc2a85f3776eae7e5be33fad03faeaedd43b04c1d21ec60458a203b2a66bf9240eee6533f042203035916f57dd363bfee3f37016e774d9fd7d95e064833584137cbf189670b3c5c15a9cc7d5c2a43c1545587e34dc7530d4722b15a08409d29676c0270e968147ffd5ad9314385786c29d59dcf0eda14395bfb6dd904cbfe7dbedf0c55d3072ec1a75405f36ced74dd9c6aff65d08ba8cd9b3233c683c58674c5dd960110debfcb2ae148855b4b36b96113877b9ba5a111f08c14aa7bfc305e53eaa2e436f38bba47e00c99d5ef850cf027516343457fecc93ef922de818d6bf4a45deec8c217e220bea56c438c55b48d71ff01a908950edfdf',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [109, 110, 111],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'A data structure problemis a computational problem involving the storage and retrieval of elements for\\nimplementing abstract data types such as lists, sets, maps, and priority queues. These include:'}}]},\n",
              " {'position': 2399,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': 'e33526ed-1e5c-4263-9cc0-b225ec93c734',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-16T20:09:50.703258033Z',\n",
              "     'updated_on': '2025-06-16T20:11:32.980858639Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2Fe33526ed-1e5c-4263-9cc0-b225ec93c734.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=8890bd0c766f4fc2a85f3776eae7e5be33fad03faeaedd43b04c1d21ec60458a203b2a66bf9240eee6533f042203035916f57dd363bfee3f37016e774d9fd7d95e064833584137cbf189670b3c5c15a9cc7d5c2a43c1545587e34dc7530d4722b15a08409d29676c0270e968147ffd5ad9314385786c29d59dcf0eda14395bfb6dd904cbfe7dbedf0c55d3072ec1a75405f36ced74dd9c6aff65d08ba8cd9b3233c683c58674c5dd960110debfcb2ae148855b4b36b96113877b9ba5a111f08c14aa7bfc305e53eaa2e436f38bba47e00c99d5ef850cf027516343457fecc93ef922de818d6bf4a45deec8c217e220bea56c438c55b48d71ff01a908950edfdf',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [109, 110, 111],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': '• searching, or the problem of retrieving a target element from a collection of elements\\n100 3 • Data Structures and Algorithms'}}]},\n",
              " {'position': 2456,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [109, 110, 111],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'Access for free at openstax.org• sorting, or the problem of rearranging elements into a logical order'}}]},\n",
              " {'position': 2524,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [109, 110, 111],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': '• hashing, or the problem of assigning a meaningful integer index for each object'}}]},\n",
              " {'position': 2610,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [109, 110, 111],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'A graph problem is a computational problem involving graphs that represent relationships between data.\\r\\nThese include:'}}]},\n",
              " {'position': 2684,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [109, 110, 111],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': '• traversal, or the problem of exploring all the vertices in a graph'}}]},\n",
              " {'position': 2781,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [109, 110, 111],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': '• minimum spanning tree is the problem of finding a lowest-cost way to connect all the vertices to each\\r\\nother'}}]},\n",
              " {'position': 2864,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [109, 110, 111],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': '• shortest path is the problem of finding the lowest-cost way to get from one vertex to another'}}]},\n",
              " {'position': 2962,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [109, 110, 111],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'A string problem is a computational problem involving text or information represented as a sequence of\\r\\ncharacters. Examples include:'}}]},\n",
              " {'position': 3044,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [109, 110, 111],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': '• matching, or the problem of searching for a text pattern within a document'}}]},\n",
              " {'position': 3112,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [109, 110, 111],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': '• compression, or the problem of representing information using less data storage'}}]},\n",
              " {'position': 3186,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [109, 110, 111],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': '• cryptography, or the problem of masking or obfuscating text to make it unintelligible\\r\\nModeling'}}]},\n",
              " {'position': 3325,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [56, 57, 58],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'Various patterns of execution models may be used to step through the instructions provided in an algorithm.\\r\\nSo far, we have only considered the traditional sequential (i.e., step-by-step) execution model for algorithm'}}]},\n",
              " {'position': 3401,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [56, 57, 58],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'So far, we have only considered the traditional sequential (i.e., step-by-step) execution model for algorithm\\r\\ninstructions. However, it is also possible to leverage parallelism/concurrency and recursion as alternative'}}]},\n",
              " {'position': 3488,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [56, 57, 58],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'Parallel/concurrent execution models are typically used to optimize algorithm execution efficiency. As an\\r\\nexample, if you and a friend are buying tickets for a movie and there are three independent lines, you may opt'}}]},\n",
              " {'position': 3690,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [56, 57, 58],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'example, if you and a friend are buying tickets for a movie and there are three independent lines, you may opt\\r\\nfor a parallel processing model of execution by having you and your friend join two separate lines to buy the\\r\\ntickets. In that case, you are guaranteed to be able to obtain the tickets quicker assuming one of the lines'}}]},\n",
              " {'position': 3814,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [56, 57, 58],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'model of execution. The problem-solving technique where a process calls itself in order to solve smaller\\r\\ninstances of the same problem is called recursion. It can be a powerful tool in programming because it allows'}}]},\n",
              " {'position': 3925,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [56, 57, 58],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'instances of the same problem is called recursion. It can be a powerful tool in programming because it allows\\r\\nfor elegant solutions to complex problems by breaking them down into smaller, more manageable parts. By\\r\\nleveraging recursion, programmers can write concise and efficient code to solve a wide range of problems.'}}]},\n",
              " {'position': 4028,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [56, 57, 58],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'Figure 2.7 Pseudocode lists each step, while a flowchart visually outlines the process of decision-making. (attribution: Copyright Rice\\r\\nUniversity, OpenStax, under CC BY 4.0 license)'}}]},\n",
              " {'position': 4154,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [56, 57, 58],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'University, OpenStax, under CC BY 4.0 license)\\r\\nWriting algorithms requires practice. Not everyone likes butter in their jam sandwich. The robot needs a'}}]},\n",
              " {'position': 4214,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [56, 57, 58],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'Writing algorithms requires practice. Not everyone likes butter in their jam sandwich. The robot needs a\\r\\nmethod of making sure it adds or does not add butter, depending on preferences. It is therefore necessary to'}}]},\n",
              " {'position': 4315,\n",
              "  'references': [{'file': {'name': 'textbook.pdf',\n",
              "     'id': '752a66de-dfd0-4036-a2c0-10c97ae1931d',\n",
              "     'metadata': None,\n",
              "     'created_on': '2025-06-26T21:10:58.578812211Z',\n",
              "     'updated_on': '2025-06-26T21:12:34.118317190Z',\n",
              "     'status': 'Available',\n",
              "     'percent_done': 1.0,\n",
              "     'signed_url': 'https://storage.googleapis.com/knowledge-prod-files/168c07ce-d86e-4e2c-86b8-fe2b7124a845%2F3e9a6c82-b4e9-4163-8f36-d8543b9ecc87%2F752a66de-dfd0-4036-a2c0-10c97ae1931d.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ke-prod-1%40pc-knowledge-prod.iam.gserviceaccount.com%2F20250626%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20250626T211317Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=host&response-content-disposition=inline&response-content-type=application%2Fpdf&X-Goog-Signature=9b7b35afd692a9c2221408a919b9631bfd548fbf7a5e5ef13ed811e59243a5f5b7a900dbc3bcfee9f3f5497f1a34a16fe17452f13ae865ddf1890f8e96bae0c2c6d0d121b3b7922aafab86cc2a752cd6b98b31e2359726b9477483385757356690e6221a4f9e077d7abb87a697cb709a3b150c6573e5c75e12c7a5b55c043aec6afd9738439b7b1a2b2a7d23d6afe3c31d51416187bd609fde552c10cb96d86bec18bb0e817906b161a6e879654d625d8ec0b546ed42b2b3ea057cbeb54be1660d57957d05a64159de74188a194ab095521f11c4347d370c1f8d2df1828817cc477c07de05c8fed3cdc916032682fc556371c9f455bf292078334fb055cbe2ae',\n",
              "     'error_message': None,\n",
              "     'size': 53398130.0},\n",
              "    'pages': [56, 57, 58],\n",
              "    'highlight': {'type': 'text',\n",
              "     'content': 'method of making sure it adds or does not add butter, depending on preferences. It is therefore necessary to\\r\\naccount for the following steps in the pseudocode and flowchart:\\r\\n2.1 • Computational Thinking 471. Ask whether there should be butter on the bread.'}}]}]"
            ]
          },
          "execution_count": 113,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "resp[\"citations\"]"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### So what happened under the hood?\n",
        "\n",
        "The assistant does the following:\n",
        "\n",
        "1. Takes in our message and turns it into a set of queries \n",
        "2. Runs those queries against a Pinecone VDB loaded with our data\n",
        "3. Reranks and creates contextual snippets from the returned data from Pinecone\n",
        "4. Passes those snippets and our queries to the generating LLM, in this case Claude\n",
        "5. Returns a cited response back to us!\n",
        "\n",
        "To learn more about how Assistant works, [check out this link here](https://www.pinecone.io/learn/pinecone-assistant/).\n",
        "\n",
        "But, what if instead we wanted to incorporate the response into some other pipeline? Or, if we wanted to precisely control the way the response is generated, but don't want to spend time and energy working on preprocessing/chunking/querying our data?\n",
        "\n",
        "This is where the Context API shines!"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Recieving context snippets instead of responses\n",
        "\n",
        "The Context API allows us to take advantage of the data preprocessing, chunking, and search capabilities of the Assistant, without needing to generate a response. Instead, a set of relevant snippets are returned from the Assistant, which are chunks of data from our documents. You can think of it as a search API plus some extras, that make it easy to maximize the relevance of returned documents.\n",
        "\n",
        "Instead of offloading generation to our Pinecone Assistant, we can choose just to leverage the query-understanding and subquerying capabilities to return the optimal contexts instead. This is handy for when we want to have a specialized workflow after retrieving these snippets, instead of getting the generation directly.\n",
        "\n",
        "To do so, we use the [Context API](https://docs.pinecone.io/guides/assistant/context-snippets-overview) like this:\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 114,
      "metadata": {},
      "outputs": [],
      "source": [
        "context_result = assistant.context(query=\"Can you teach me about how simple web applications are architected? I don't understand how they work.\")\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "And we get snippets back, like this:"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 115,
      "metadata": {},
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Snippet 1:\n",
            "Figure 11.1 It takes many roles to build a responsive design in web applications development for multiple system applications.\n",
            "(credit: modification of “190827-F-ND912-035” by Tech. Sgt. R. J. Biermann/Lt. Col. Wilson/U.S. Air Force, Public Domain)\n",
            "Chapter Outline\n",
            "11.1 Modern Web Applications Architectures\n",
            "11.2 Sample Responsive WAD with Bootstrap and Django\n",
            "11.3 Sample Responsive WAD with Bootstrap/React and Node\n",
            "11.4 Sample Responsive WAD with Bootstrap/React and Django\n",
            "11.5 Sample Native WAD with React Native and Node or Django\n",
            "11.6 Sample Ethereum Blockchain Web 2.0/Web 3.0 Application\n",
            "Introduction\n",
            "TechWorks is creating several web applications this year for a new product line. One application is an AI-image\n",
            "generator website and auction house for selling images. An outside consultant has been brought in, and they\n",
            "have determined that a hybrid Web 2.0/3.0 architecture is best suited for this solution. However, the\n",
            "engineering team who will perform the work needs to gain experience with Web 3.0 technologies. Therefore,\n",
            "the consultant recommended that TechWorks take a popular internal desktop application for managing to-do\n",
            "lists and re-create it as a hybrid Web 2.0/3.0-based application so engineers can gain practical experience with\n",
            "various web application frameworks and technologies, with the added benefit of accessing their to-dos from\n",
            "anywhere.\n",
            "The TechWorks engineering team has decided to perform iterative releases of the to-do application, starting\n",
            "with responsive web apps, as they will render well on various screen sizes, from large monitors to smaller\n",
            "displays like phones and tablets. Next, they will employ a native web application framework to target specific\n",
            "devices like Android and iPhones. Lastly, they will explore building a Web 2.0/3.0-based to-do application using\n",
            "blockchain technology, as they believe this approach will give them the necessary skills for creating future\n",
            "solutions.\n",
            "Web Applications Development\n",
            "1111.1 Modern Web Applications Architectures\n",
            "Learning Objectives\n",
            "By the end of this section, you will be able to:\n",
            "• Understand the use of server-side rendering and MVC patterns\n",
            "• Relate to the technology used to create responsive Web 2.0 applications\n",
            "• Become familiar with the technology used to create native mobile applications\n",
            "• Understand how to create Web 3.0 applications as well as hybrid Web 2.0/3.0 applications\n",
            "The World Wide Web, or the Web as it is known today, started as a way to link content (primarily text and\n",
            "images) stored on different servers or machines. It was invented by Tim Berners-Lee in 1989 while he worked\n",
            "as a researcher at the European Organization for Nuclear Research (CERN), home to the European Particle\n",
            "Physics Laboratory. Sir Tim Berners-Lee was knighted by Queen Elizabeth II in 2004 for his pioneering work. He\n",
            "created the Hypertext Transfer Protocol (HTTP) that operates on top of Transmission Control Protocol/Internet\n",
            "Protocol (TCP/IP), the principal protocols used on the Internet. Clients (web browsers) transmit HTTP requests\n",
            "to a web server, which is a software application that runs at a Uniform Resource Locator (URL) that specifies a\n",
            "location on the Web to access it, and responds by providing pages rendered in the hypertext markup language\n",
            "(HTML). This simple request and response paradigm, a client-server model, was easy to implement and\n",
            "allowed for the rapid growth of the Web. This phase of the Web, which began after 1989 and ended around\n",
            "2004, would become known as Web 1.0, a period where the user’s interaction was limited primarily to reading\n",
            "and selecting web pages. A web page is a document commonly written in HTML and viewed in a browser.\n",
            "Figure 11.2 shows a simple Web 1.0 architecture and common usage. An encryption layer was later added to\n",
            "the HTTP protocol, which resulted in creating the HTTPS protocol. This made it possible to protect the sharing\n",
            "of sensitive information over the Web from eavesdropping attacks. While web servers only served web pages\n",
            "initially, a Common Gateway Interface (CGI) was subsequently added after the initial implementation of web\n",
            "servers to make it possible to link to applications via URLs on the Web.\n",
            "Figure 11.2 This architecture outlines a user’s interaction with a Web 1.0 website. (attribution: Copyright Rice University, OpenStax,\n",
            "under CC BY 4.0 license)\n",
            "As the Web evolved from this basic architecture, the need for more dynamic and interactive experiences\n",
            "became apparent. Users were no longer content with simply viewing static pages; they wanted to contribute\n",
            "content and engage with other users. Also called online publishing, web publishing publishes content on the\n",
            "Web while applying traditional publishing models. It was akin to digitizing an encyclopedia (images and text)\n",
            "566 11 • Web Applications Development\n",
            "Access for free at openstax.organd putting it online with hyperlinks. Today, simple websites with limited functionality, such as early blogs or\n",
            "static sites, still follow this model. A more interactive model that could scale to meet user demand was needed\n",
            "to support users’ desire to provide content and interact with other users. A design pattern is a reusable\n",
            "solution to a common software design problem. Figure 11.3 illustrates the Model-View-Controller (MVC) design\n",
            "pattern that was employed to separate a traditional web application’s data model, presentation, and business\n",
            "logic layers into its components.\n",
            "Figure 11.3 This figure shows a user’s interaction with the Model-View-Controller pattern. (attribution: Copyright Rice University,\n",
            "OpenStax, under CC BY 4.0 license)\n",
            "The original implementation of the MVC pattern on the Web was such that the View would send requests to\n",
            "the Controller and the Controller obtained data from the Model and rendered it within HTML pages that were\n",
            "passed to browsers for presentation purposes. AJAX technology was later introduced to enable a more\n",
            "complete implementation of MVC on the Web that allowed asynchronous updates to page components and\n",
            "did not require refreshing pages in the browser to fetch data.\n",
            "Following Moore’s law, which states that the number of transistors on an integrated circuit doubles roughly\n",
            "every two years, the processing power of smaller devices like laptops, tablets, and mobile phones became the\n",
            "preferred way users interacted on the Web. As Internet data transfer speeds and bandwidth increased through\n",
            "better hardware, fiber-optic cables, and mobile wireless technology, the rendering of web applications’\n",
            "interactive interfaces moved from the server side to the client side. This led to being able to run native\n",
            "applications (apps) on mobile wireless phones that could take advantage of specific device rendering features.\n",
            "In a paradigm shift th\n",
            "----------------------------------------------------------------------------------------------------\n",
            "\n",
            "\n",
            "Snippet 2:\n",
            "Figure 11.1 It takes many roles to build a responsive design in web applications development for multiple system applications.\n",
            "(credit: modification of “190827-F-ND912-035” by Tech. Sgt. R. J. Biermann/Lt. Col. Wilson/U.S. Air Force, Public Domain)\n",
            "Chapter Outline\n",
            "11.1 Modern Web Applications Architectures\n",
            "11.2 Sample Responsive WAD with Bootstrap and Django\n",
            "11.3 Sample Responsive WAD with Bootstrap/React and Node\n",
            "11.4 Sample Responsive WAD with Bootstrap/React and Django\n",
            "11.5 Sample Native WAD with React Native and Node or Django\n",
            "11.6 Sample Ethereum Blockchain Web 2.0/Web 3.0 Application\n",
            "Introduction\n",
            "TechWorks is creating several web applications this year for a new product line. One application is an AI-image\n",
            "generator website and auction house for selling images. An outside consultant has been brought in, and they\n",
            "have determined that a hybrid Web 2.0/3.0 architecture is best suited for this solution. However, the\n",
            "engineering team who will perform the work needs to gain experience with Web 3.0 technologies. Therefore,\n",
            "the consultant recommended that TechWorks take a popular internal desktop application for managing to-do\n",
            "lists and re-create it as a hybrid Web 2.0/3.0-based application so engineers can gain practical experience with\n",
            "various web application frameworks and technologies, with the added benefit of accessing their to-dos from\n",
            "anywhere.\n",
            "The TechWorks engineering team has decided to perform iterative releases of the to-do application, starting\n",
            "with responsive web apps, as they will render well on various screen sizes, from large monitors to smaller\n",
            "displays like phones and tablets. Next, they will employ a native web application framework to target specific\n",
            "devices like Android and iPhones. Lastly, they will explore building a Web 2.0/3.0-based to-do application using\n",
            "blockchain technology, as they believe this approach will give them the necessary skills for creating future\n",
            "solutions.\n",
            "Web Applications Development\n",
            "1111.1 Modern Web Applications Architectures\n",
            "Learning Objectives\n",
            "By the end of this section, you will be able to:\n",
            "• Understand the use of server-side rendering and MVC patterns\n",
            "• Relate to the technology used to create responsive Web 2.0 applications\n",
            "• Become familiar with the technology used to create native mobile applications\n",
            "• Understand how to create Web 3.0 applications as well as hybrid Web 2.0/3.0 applications\n",
            "The World Wide Web, or the Web as it is known today, started as a way to link content (primarily text and\n",
            "images) stored on different servers or machines. It was invented by Tim Berners-Lee in 1989 while he worked\n",
            "as a researcher at the European Organization for Nuclear Research (CERN), home to the European Particle\n",
            "Physics Laboratory. Sir Tim Berners-Lee was knighted by Queen Elizabeth II in 2004 for his pioneering work. He\n",
            "created the Hypertext Transfer Protocol (HTTP) that operates on top of Transmission Control Protocol/Internet\n",
            "Protocol (TCP/IP), the principal protocols used on the Internet. Clients (web browsers) transmit HTTP requests\n",
            "to a web server, which is a software application that runs at a Uniform Resource Locator (URL) that specifies a\n",
            "location on the Web to access it, and responds by providing pages rendered in the hypertext markup language\n",
            "(HTML). This simple request and response paradigm, a client-server model, was easy to implement and\n",
            "allowed for the rapid growth of the Web. This phase of the Web, which began after 1989 and ended around\n",
            "2004, would become known as Web 1.0, a period where the user’s interaction was limited primarily to reading\n",
            "and selecting web pages. A web page is a document commonly written in HTML and viewed in a browser.\n",
            "Figure 11.2 shows a simple Web 1.0 architecture and common usage. An encryption layer was later added to\n",
            "the HTTP protocol, which resulted in creating the HTTPS protocol. This made it possible to protect the sharing\n",
            "of sensitive information over the Web from eavesdropping attacks. While web servers only served web pages\n",
            "initially, a Common Gateway Interface (CGI) was subsequently added after the initial implementation of web\n",
            "servers to make it possible to link to applications via URLs on the Web.\n",
            "Figure 11.2 This architecture outlines a user’s interaction with a Web 1.0 website. (attribution: Copyright Rice University, OpenStax,\n",
            "under CC BY 4.0 license)\n",
            "As the Web evolved from this basic architecture, the need for more dynamic and interactive experiences\n",
            "became apparent. Users were no longer content with simply viewing static pages; they wanted to contribute\n",
            "content and engage with other users. Also called online publishing, web publishing publishes content on the\n",
            "Web while applying traditional publishing models. It was akin to digitizing an encyclopedia (images and text)\n",
            "566 11 • Web Applications Development\n",
            "Access for free at openstax.organd putting it online with hyperlinks. Today, simple websites with limited functionality, such as early blogs or\n",
            "static sites, still follow this model. A more interactive model that could scale to meet user demand was needed\n",
            "to support users’ desire to provide content and interact with other users. A design pattern is a reusable\n",
            "solution to a common software design problem. Figure 11.3 illustrates the Model-View-Controller (MVC) design\n",
            "pattern that was employed to separate a traditional web application’s data model, presentation, and business\n",
            "logic layers into its components.\n",
            "Figure 11.3 This figure shows a user’s interaction with the Model-View-Controller pattern. (attribution: Copyright Rice University,\n",
            "OpenStax, under CC BY 4.0 license)\n",
            "The original implementation of the MVC pattern on the Web was such that the View would send requests to\n",
            "the Controller and the Controller obtained data from the Model and rendered it within HTML pages that were\n",
            "passed to browsers for presentation purposes. AJAX technology was later introduced to enable a more\n",
            "complete implementation of MVC on the Web that allowed asynchronous updates to page components and\n",
            "did not require refreshing pages in the browser to fetch data.\n",
            "Following Moore’s law, which states that the number of transistors on an integrated circuit doubles roughly\n",
            "every two years, the processing power of smaller devices like laptops, tablets, and mobile phones became the\n",
            "preferred way users interacted on the Web. As Internet data transfer speeds and bandwidth increased through\n",
            "better hardware, fiber-optic cables, and mobile wireless technology, the rendering of web applications’\n",
            "interactive interfaces moved from the server side to the client side. This led to being able to run native\n",
            "applications (apps) on mobile wireless phones that could take advantage of specific device rendering features.\n",
            "In a paradigm shift th\n",
            "----------------------------------------------------------------------------------------------------\n",
            "\n",
            "\n",
            "Snippet 3:\n",
            "Figure11.1 It takes many roles to build a responsive design in web applications development for multiple system applications.\n",
            "(credit: modification of “190827-F-ND912-035” by Tech. Sgt. R. J. Biermann/Lt. Col. Wilson/U.S. Air Force, Public Domain)\n",
            "Chapter Outline\n",
            "11.1Modern Web Applications Architectures\n",
            "11.2Sample Responsive WAD with Bootstrap and Django\n",
            "11.3Sample Responsive WAD with Bootstrap/React and Node\n",
            "11.4Sample Responsive WAD with Bootstrap/React and Django\n",
            "11.5Sample Native WAD with React Native and Node or Django\n",
            "11.6Sample Ethereum Blockchain Web 2.0/Web 3.0 Application\n",
            "Introduction\n",
            "TechWorks is creating several web applications this year for a new product line. One application is an AI-image\n",
            "generator website and auction house for selling images. An outside consultant has been brought in, and they\n",
            "have determined that a hybrid Web 2.0/3.0 architecture is best suited for this solution. However, the\n",
            "engineering team who will perform the work needs to gain experience with Web 3.0 technologies. Therefore,\n",
            "the consultant recommended that TechWorks take a popular internal desktop application for managing to-do\n",
            "lists and re-create it as a hybrid Web 2.0/3.0-based application so engineers can gain practical experience with\n",
            "various web application frameworks and technologies, with the added benefit of accessing their to-dos from\n",
            "anywhere.\n",
            "The TechWorks engineering team has decided to perform iterative releases of the to-do application, starting\n",
            "with responsive web apps, as they will render well on various screen sizes, from large monitors to smaller\n",
            "displays like phones and tablets. Next, they will employ a native web application framework to target specific\n",
            "devices like Android and iPhones. Lastly, they will explore building a Web 2.0/3.0-based to-do application using\n",
            "blockchain technology, as they believe this approach will give them the necessary skills for creating future\n",
            "solutions.\n",
            "Web Applications Development\n",
            "11\n",
            "11.1 Modern Web Applications Architectures\n",
            "Learning Objectives\n",
            "By the end of this section, you will be able to:\n",
            "• Understand the use of server-side rendering and MVC patterns\n",
            "• Relate to the technology used to create responsive Web 2.0 applications\n",
            "• Become familiar with the technology used to create native mobile applications\n",
            "• Understand how to create Web 3.0 applications as well as hybrid Web 2.0/3.0 applications\n",
            "The World Wide Web, or the Webas it is known today, started as a way to link content (primarily text and\n",
            "images) stored on different servers or machines. It was invented by Tim Berners-Lee in 1989 while he worked\n",
            "as a researcher at the European Organization for Nuclear Research (CERN), home to the European Particle\n",
            "Physics Laboratory. Sir Tim Berners-Lee was knighted by Queen Elizabeth II in 2004 for his pioneering work. He\n",
            "created the Hypertext Transfer Protocol (HTTP) that operates on top of Transmission Control Protocol/Internet\n",
            "Protocol (TCP/IP), the principal protocols used on the Internet. Clients (web browsers) transmit HTTP requests\n",
            "to a web server, which is a software application that runs at a Uniform Resource Locator (URL) that specifies a\n",
            "location on the Web to access it, and responds by providing pages rendered in the hypertext markup language\n",
            "(HTML). This simple request and response paradigm, a client-server model, was easy to implement and\n",
            "allowed for the rapid growth of the Web. This phase of the Web, which began after 1989 and ended around\n",
            "2004, would become known as Web 1.0, a period where the user’s interaction was limited primarily to reading\n",
            "and selecting web pages. A web pageis a document commonly written in HTML and viewed in a browser.\n",
            "Figure 11.2 shows a simple Web 1.0 architecture and common usage. An encryption layer was later added to\n",
            "the HTTP protocol, which resulted in creating the HTTPS protocol. This made it possible to protect the sharing\n",
            "of sensitive information over the Web from eavesdropping attacks. While web servers only served web pages\n",
            "initially, a Common Gateway Interface (CGI) was subsequently added after the initial implementation of web\n",
            "servers to make it possible to link to applications via URLs on the Web.\n",
            "Figure11.2 This architecture outlines a user’s interaction with a Web 1.0 website. (attribution: Copyright Rice University, OpenStax,\n",
            "under CC BY 4.0 license)\n",
            "As the Web evolved from this basic architecture, the need for more dynamic and interactive experiences\n",
            "became apparent. Users were no longer content with simply viewing static pages; they wanted to contribute\n",
            "content and engage with other users. Also called online publishing, web publishingpublishes content on the\n",
            "Web while applying traditional publishing models. It was akin to digitizing an encyclopedia (images and text)\n",
            "566 11 • Web Applications Development\n",
            "Access for free at openstax.organd putting it online with hyperlinks. Today, simple websites with limited functionality, such as early blogs or\n",
            "static sites, still follow this model. A more interactive model that could scale to meet user demand was needed\n",
            "to support users’ desire to provide content and interact with other users. A design pattern is a reusable\n",
            "solution to a common software design problem. Figure 11.3 illustrates the Model-View-Controller (MVC) design\n",
            "pattern that was employed to separate a traditional web application’s data model, presentation, and business\n",
            "logic layers into its components.\n",
            "Figure11.3 This figure shows a user’s interaction with the Model-View-Controller pattern. (attribution: Copyright Rice University,\n",
            "OpenStax, under CC BY 4.0 license)\n",
            "The original implementation of the MVC pattern on the Web was such that the View would send requests to\n",
            "the Controller and the Controller obtained data from the Model and rendered it within HTML pages that were\n",
            "passed to browsers for presentation purposes. AJAX technology was later introduced to enable a more\n",
            "complete implementation of MVC on the Web that allowed asynchronous updates to page components and\n",
            "did not require refreshing pages in the browser to fetch data.\n",
            "Following Moore’s law, which states that the number of transistors on an integrated circuit doubles roughly\n",
            "every two years, the processing power of smaller devices like laptops, tablets, and mobile phones became the\n",
            "preferred way users interacted on the Web. As Internet data transfer speeds and bandwidth increased through\n",
            "better hardware, fiber-optic cables, and mobile wireless technology, the rendering of web applications’\n",
            "interactive interfaces moved from the server side to the client side. This led to being able to run native\n",
            "applications (apps) on mobile wireless phones that could take advantage of specific device rendering features.\n",
            "In a paradigm shift that was opposite to web apps, the data model moved off the phone and onto remote\n",
            "server\n",
            "----------------------------------------------------------------------------------------------------\n",
            "\n",
            "\n",
            "Snippet 4:\n",
            "ed to describe the structure and content\n",
            "of web data\n",
            "JavaScript (JS) scripting language that adds interactivity to web content and server-side functionality\n",
            "JavaScript Object Notation (JSON) file format that represents data as text-based attribute-value information\n",
            "Jetpack Compose toolkit for building native user interfaces\n",
            "loose coupling component in a software system that has a weak association with the other components\n",
            "Metro bundler bundles the JavaScript code that is deployed on the mobile device or emulator when the\n",
            "React Native front-end application is successfully created\n",
            "Moore’s law states that the number of transistors on an integrated circuit doubles roughly every two years\n",
            "Node JavaScript runtime environment that provides users with the tools to develop web applications, as well\n",
            "as servers, scripts, and command-line tools\n",
            "non-fungible token (NFT) unique digital identifier on a blockchain\n",
            "optimistic rollup protocol that increases transaction output by bundling multiple transactions into batches,\n",
            "which are processed off-chain\n",
            "peer-to-peer (P2P) network one in which devices connect and can share data and processing without\n",
            "needing a centralized server\n",
            "Postman API platform testing tool that can be used as a client\n",
            "React JavaScript library popular to build user interfaces\n",
            "React Native open-source JavaScript framework used to build native applications for mobile devices\n",
            "Semantic Web system of autonomous agents, which are software programs that respond to events\n",
            "serializer tool to control response outputs and convert complex data into content, such as JSON\n",
            "sidechain secondary blockchain that aggregates blocks back to the main blockchain\n",
            "Solidity high-level, object-oriented language focused on the implementation of smart contracts\n",
            "stateful application software and system that maintains the state of an application over time\n",
            "stateless application state is not maintained by the system and previous actions do not impact future ones\n",
            "Truffle Framework popular suite of tools used to develop smart contracts\n",
            "View presentation layer that handles the user interface\n",
            "Web 1.0 phase of the Web where the user’s interaction was limited primarily to reading and selecting web\n",
            "pages\n",
            "web page document commonly written in HTML and viewed in a browser\n",
            "web publishing also called online publishing; is for publishing content on the Web\n",
            "web server software application that runs at a known URL and responds to HTTP requests\n",
            "656 11 • Chapter Review\n",
            "Access for free at openstax.orgWorld Wide Web (the Web) started as a way to link content (primarily text and images) stored on different\n",
            "servers or machines\n",
            "Xcode Apple’s IDE that enables application development for Apple’s platforms\n",
            "zero-knowledge rollup (zk-rollup) protocol that bundles transactions into batches that are executed off the\n",
            "mainnet\n",
            "Summary\n",
            "11.1Modern Web Applications Architectures\n",
            "• The Web is defined by phases, each denoted by its principal usage—W eb 1.0 for reading content, Web 2.0\n",
            "regarding social interaction, and Web 3.0 as an open, decentralized, and trusted web.\n",
            "• Traditional web architectures rendered web pages on the server, with each client request resulting in a\n",
            "new HTML page being sent from the server to the browser. The Model-View-Controller (MVC) pattern was\n",
            "often used for server-side development.\n",
            "• Responsive web applications render effectively in a browser regardless of the user’s device screen or\n",
            "orientation.\n",
            "• Single-page applications (SPAs) load one web page in the browser, manipulating the UI and fetching data\n",
            "through APIs. This is often done with JavaScript making AJAX calls to REST APIs.\n",
            "• Native mobile applications are designed to run on a specific device. They have the advantage of\n",
            "performance and access to data and functionality on the device but suffer from a lack of cross-platform\n",
            "support.\n",
            "• Web 3.0 is the next phase of the Web. Technologies that will be needed to support it will likely include\n",
            "distributed ledger technologies and AI.\n",
            "• Future web architectures will likely see a combination of Web 2.0 and 3.0 architectural models to support\n",
            "decentralization, openness, trust, cost, and performance effectively. This hybrid approach solves some\n",
            "problems while not fully addressing the goals of Web 3.0.\n",
            "11.2Sample Responsive WAD with Bootstrap and Django\n",
            "• Bootstrap is an open-source, responsive web application framework, and Django is a Python-based web\n",
            "application development framework. Both frameworks are highly popular due to their ease of use.\n",
            "• To build the Todo application, you must install Python, PIP, Django, Django REST Framework, Bootstrap,\n",
            "and jQuery.\n",
            "• The steps to build the Todo application are install and set up a local programming environment for Python\n",
            "3, download and install Python 3.9.4, and add Python and its Scripts subfolder to your path environment\n",
            "data.\n",
            "• The first step to build a Django web application is to create a Django project.\n",
            "• Once the Django project is successfully completed and set up, the next step is to create the Todo\n",
            "application and register it in the Django project.\n",
            "• After registering and installing the Todo web application, the next step is to create the models for\n",
            "Category and TodoList.\n",
            "• After the Category and TodoList models are created, the next step is to create the serializers, the View,\n",
            "routers, user interface, and templates.\n",
            "11.3Sample Responsive WAD with Bootstrap/React and Node\n",
            "• React is a JavaScript library popular to build user interfaces.\n",
            "• Node is a JavaScript runtime environment that provides developers with the tools to develop web\n",
            "applications, as well as servers, scripts, and command-line tools.\n",
            "• When creating a Todo web application using React and Node, React serves as the front end, handling the\n",
            "user interface, as well as getting and setting data via HTTP requests using Axios. Node serves as the back\n",
            "end, using a REST API built with ExpressJS and the MongooseJS ODM to interact with a MongoDB\n",
            "database.\n",
            "• To build the Todo application using Bootstrap, React, and Node, you need React v17.0.2, Bootstrap v4.5.0,\n",
            "11 • Chapter Review 657Node v14.17.5, ExpressJS v4.17.2, MongooseJS v6.1.9, and Axios v0.21.0.\n",
            "• The steps to create a Todo web application using Bootstrap, React, and Node include:\n",
            "◦ create the Node back end\n",
            "◦ create the Node app\n",
            "◦ set up the Express web server\n",
            "◦ configure the MongoDB database and Mongoose\n",
            "◦ build the controller\n",
            "◦ set up the REST API\n",
            "◦ create the React front end\n",
            "◦ create the React app\n",
            "◦ install Bootstrap and other dependencies\n",
            "◦ create the React components\n",
            "◦ connect the React front end to the Node back end\n",
            "11.4Sample Responsive WAD with Bootstrap/React and Django\n",
            "• The Todo web application can be updated using Bootstrap with React and Django.\n",
            "• For this version of the Todo \n",
            "----------------------------------------------------------------------------------------------------\n",
            "\n",
            "\n",
            "Snippet 5:\n",
            "eb data\n",
            "JavaScript (JS) scripting language that adds interactivity to web content and server-side functionality\n",
            "JavaScript Object Notation (JSON) file format that represents data as text-based attribute-value information\n",
            "Jetpack Compose toolkit for building native user interfaces\n",
            "loose coupling component in a software system that has a weak association with the other components\n",
            "Metro bundler bundles the JavaScript code that is deployed on the mobile device or emulator when the\n",
            "React Native front-end application is successfully created\n",
            "Moore’s law states that the number of transistors on an integrated circuit doubles roughly every two years\n",
            "Node JavaScript runtime environment that provides users with the tools to develop web applications, as well\n",
            "as servers, scripts, and command-line tools\n",
            "non-fungible token (NFT) unique digital identifier on a blockchain\n",
            "optimistic rollup protocol that increases transaction output by bundling multiple transactions into batches,\n",
            "which are processed off-chain\n",
            "peer-to-peer (P2P) network one in which devices connect and can share data and processing without\n",
            "needing a centralized server\n",
            "Postman API platform testing tool that can be used as a client\n",
            "React JavaScript library popular to build user interfaces\n",
            "React Native open-source JavaScript framework used to build native applications for mobile devices\n",
            "Semantic Web system of autonomous agents, which are software programs that respond to events\n",
            "serializer tool to control response outputs and convert complex data into content, such as JSON\n",
            "sidechain secondary blockchain that aggregates blocks back to the main blockchain\n",
            "Solidity high-level, object-oriented language focused on the implementation of smart contracts\n",
            "stateful application software and system that maintains the state of an application over time\n",
            "stateless application state is not maintained by the system and previous actions do not impact future ones\n",
            "Truffle Framework popular suite of tools used to develop smart contracts\n",
            "View presentation layer that handles the user interface\n",
            "Web 1.0 phase of the Web where the user’s interaction was limited primarily to reading and selecting web\n",
            "pages\n",
            "web page document commonly written in HTML and viewed in a browser\n",
            "web publishing also called online publishing; is for publishing content on the Web\n",
            "web server software application that runs at a known URL and responds to HTTP requests\n",
            "656 11 • Chapter Review\n",
            "Access for free at openstax.orgWorld Wide Web (the Web) started as a way to link content (primarily text and images) stored on different\n",
            "servers or machines\n",
            "Xcode Apple’s IDE that enables application development for Apple’s platforms\n",
            "zero-knowledge rollup (zk-rollup) protocol that bundles transactions into batches that are executed off the\n",
            "mainnet\n",
            "Summary\n",
            "11.1 Modern Web Applications Architectures\n",
            "• The Web is defined by phases, each denoted by its principal usage—Web 1.0 for reading content, Web 2.0\n",
            "regarding social interaction, and Web 3.0 as an open, decentralized, and trusted web.\n",
            "• Traditional web architectures rendered web pages on the server, with each client request resulting in a\n",
            "new HTML page being sent from the server to the browser. The Model-View-Controller (MVC) pattern was\n",
            "often used for server-side development.\n",
            "• Responsive web applications render effectively in a browser regardless of the user’s device screen or\n",
            "orientation.\n",
            "• Single-page applications (SPAs) load one web page in the browser, manipulating the UI and fetching data\n",
            "through APIs. This is often done with JavaScript making AJAX calls to REST APIs.\n",
            "• Native mobile applications are designed to run on a specific device. They have the advantage of\n",
            "performance and access to data and functionality on the device but suffer from a lack of cross-platform\n",
            "support.\n",
            "• Web 3.0 is the next phase of the Web. Technologies that will be needed to support it will likely include\n",
            "distributed ledger technologies and AI.\n",
            "• Future web architectures will likely see a combination of Web 2.0 and 3.0 architectural models to support\n",
            "decentralization, openness, trust, cost, and performance effectively. This hybrid approach solves some\n",
            "problems while not fully addressing the goals of Web 3.0.\n",
            "11.2 Sample Responsive WAD with Bootstrap and Django\n",
            "• Bootstrap is an open-source, responsive web application framework, and Django is a Python-based web\n",
            "application development framework. Both frameworks are highly popular due to their ease of use.\n",
            "• To build the Todo application, you must install Python, PIP, Django, Django REST Framework, Bootstrap,\n",
            "and jQuery.\n",
            "• The steps to build the Todo application are install and set up a local programming environment for Python\n",
            "3, download and install Python 3.9.4, and add Python and its Scripts subfolder to your path environment\n",
            "data.\n",
            "• The first step to build a Django web application is to create a Django project.\n",
            "• Once the Django project is successfully completed and set up, the next step is to create the Todo\n",
            "application and register it in the Django project.\n",
            "• After registering and installing the Todo web application, the next step is to create the models for\n",
            "Category and TodoList.\n",
            "• After the Category and TodoList models are created, the next step is to create the serializers, the View,\n",
            "routers, user interface, and templates.\n",
            "11.3 Sample Responsive WAD with Bootstrap/React and Node\n",
            "• React is a JavaScript library popular to build user interfaces.\n",
            "• Node is a JavaScript runtime environment that provides developers with the tools to develop web\n",
            "applications, as well as servers, scripts, and command-line tools.\n",
            "• When creating a Todo web application using React and Node, React serves as the front end, handling the\n",
            "user interface, as well as getting and setting data via HTTP requests using Axios. Node serves as the back\n",
            "end, using a REST API built with ExpressJS and the MongooseJS ODM to interact with a MongoDB\n",
            "database.\n",
            "• To build the Todo application using Bootstrap, React, and Node, you need React v17.0.2, Bootstrap v4.5.0,\n",
            "11 • Chapter Review 657Node v14.17.5, ExpressJS v4.17.2, MongooseJS v6.1.9, and Axios v0.21.0.\n",
            "• The steps to create a Todo web application using Bootstrap, React, and Node include:\n",
            "◦ create the Node back end\n",
            "◦ create the Node app\n",
            "◦ set up the Express web server\n",
            "◦ configure the MongoDB database and Mongoose\n",
            "◦ build the controller\n",
            "◦ set up the REST API\n",
            "◦ create the React front end\n",
            "◦ create the React app\n",
            "◦ install Bootstrap and other dependencies\n",
            "◦ create the React components\n",
            "◦ connect the React front end to the Node back end\n",
            "11.4 Sample Responsive WAD with Bootstrap/React and Django\n",
            "• The Todo web application can be updated using Bootstrap with\n",
            "----------------------------------------------------------------------------------------------------\n",
            "\n",
            "\n",
            "Snippet 6:\n",
            "eb data\n",
            "JavaScript (JS) scripting language that adds interactivity to web content and server-side functionality\n",
            "JavaScript Object Notation (JSON) file format that represents data as text-based attribute-value information\n",
            "Jetpack Compose toolkit for building native user interfaces\n",
            "loose coupling component in a software system that has a weak association with the other components\n",
            "Metro bundler bundles the JavaScript code that is deployed on the mobile device or emulator when the\n",
            "React Native front-end application is successfully created\n",
            "Moore’s law states that the number of transistors on an integrated circuit doubles roughly every two years\n",
            "Node JavaScript runtime environment that provides users with the tools to develop web applications, as well\n",
            "as servers, scripts, and command-line tools\n",
            "non-fungible token (NFT) unique digital identifier on a blockchain\n",
            "optimistic rollup protocol that increases transaction output by bundling multiple transactions into batches,\n",
            "which are processed off-chain\n",
            "peer-to-peer (P2P) network one in which devices connect and can share data and processing without\n",
            "needing a centralized server\n",
            "Postman API platform testing tool that can be used as a client\n",
            "React JavaScript library popular to build user interfaces\n",
            "React Native open-source JavaScript framework used to build native applications for mobile devices\n",
            "Semantic Web system of autonomous agents, which are software programs that respond to events\n",
            "serializer tool to control response outputs and convert complex data into content, such as JSON\n",
            "sidechain secondary blockchain that aggregates blocks back to the main blockchain\n",
            "Solidity high-level, object-oriented language focused on the implementation of smart contracts\n",
            "stateful application software and system that maintains the state of an application over time\n",
            "stateless application state is not maintained by the system and previous actions do not impact future ones\n",
            "Truffle Framework popular suite of tools used to develop smart contracts\n",
            "View presentation layer that handles the user interface\n",
            "Web 1.0 phase of the Web where the user’s interaction was limited primarily to reading and selecting web\n",
            "pages\n",
            "web page document commonly written in HTML and viewed in a browser\n",
            "web publishing also called online publishing; is for publishing content on the Web\n",
            "web server software application that runs at a known URL and responds to HTTP requests\n",
            "656 11 • Chapter Review\n",
            "Access for free at openstax.orgWorld Wide Web (the Web) started as a way to link content (primarily text and images) stored on different\n",
            "servers or machines\n",
            "Xcode Apple’s IDE that enables application development for Apple’s platforms\n",
            "zero-knowledge rollup (zk-rollup) protocol that bundles transactions into batches that are executed off the\n",
            "mainnet\n",
            "Summary\n",
            "11.1 Modern Web Applications Architectures\n",
            "• The Web is defined by phases, each denoted by its principal usage—Web 1.0 for reading content, Web 2.0\n",
            "regarding social interaction, and Web 3.0 as an open, decentralized, and trusted web.\n",
            "• Traditional web architectures rendered web pages on the server, with each client request resulting in a\n",
            "new HTML page being sent from the server to the browser. The Model-View-Controller (MVC) pattern was\n",
            "often used for server-side development.\n",
            "• Responsive web applications render effectively in a browser regardless of the user’s device screen or\n",
            "orientation.\n",
            "• Single-page applications (SPAs) load one web page in the browser, manipulating the UI and fetching data\n",
            "through APIs. This is often done with JavaScript making AJAX calls to REST APIs.\n",
            "• Native mobile applications are designed to run on a specific device. They have the advantage of\n",
            "performance and access to data and functionality on the device but suffer from a lack of cross-platform\n",
            "support.\n",
            "• Web 3.0 is the next phase of the Web. Technologies that will be needed to support it will likely include\n",
            "distributed ledger technologies and AI.\n",
            "• Future web architectures will likely see a combination of Web 2.0 and 3.0 architectural models to support\n",
            "decentralization, openness, trust, cost, and performance effectively. This hybrid approach solves some\n",
            "problems while not fully addressing the goals of Web 3.0.\n",
            "11.2 Sample Responsive WAD with Bootstrap and Django\n",
            "• Bootstrap is an open-source, responsive web application framework, and Django is a Python-based web\n",
            "application development framework. Both frameworks are highly popular due to their ease of use.\n",
            "• To build the Todo application, you must install Python, PIP, Django, Django REST Framework, Bootstrap,\n",
            "and jQuery.\n",
            "• The steps to build the Todo application are install and set up a local programming environment for Python\n",
            "3, download and install Python 3.9.4, and add Python and its Scripts subfolder to your path environment\n",
            "data.\n",
            "• The first step to build a Django web application is to create a Django project.\n",
            "• Once the Django project is successfully completed and set up, the next step is to create the Todo\n",
            "application and register it in the Django project.\n",
            "• After registering and installing the Todo web application, the next step is to create the models for\n",
            "Category and TodoList.\n",
            "• After the Category and TodoList models are created, the next step is to create the serializers, the View,\n",
            "routers, user interface, and templates.\n",
            "11.3 Sample Responsive WAD with Bootstrap/React and Node\n",
            "• React is a JavaScript library popular to build user interfaces.\n",
            "• Node is a JavaScript runtime environment that provides developers with the tools to develop web\n",
            "applications, as well as servers, scripts, and command-line tools.\n",
            "• When creating a Todo web application using React and Node, React serves as the front end, handling the\n",
            "user interface, as well as getting and setting data via HTTP requests using Axios. Node serves as the back\n",
            "end, using a REST API built with ExpressJS and the MongooseJS ODM to interact with a MongoDB\n",
            "database.\n",
            "• To build the Todo application using Bootstrap, React, and Node, you need React v17.0.2, Bootstrap v4.5.0,\n",
            "11 • Chapter Review 657Node v14.17.5, ExpressJS v4.17.2, MongooseJS v6.1.9, and Axios v0.21.0.\n",
            "• The steps to create a Todo web application using Bootstrap, React, and Node include:\n",
            "◦ create the Node back end\n",
            "◦ create the Node app\n",
            "◦ set up the Express web server\n",
            "◦ configure the MongoDB database and Mongoose\n",
            "◦ build the controller\n",
            "◦ set up the REST API\n",
            "◦ create the React front end\n",
            "◦ create the React app\n",
            "◦ install Bootstrap and other dependencies\n",
            "◦ create the React components\n",
            "◦ connect the React front end to the Node back end\n",
            "11.4 Sample Responsive WAD with Bootstrap/React and Django\n",
            "• The Todo web application can be updated using Bootstrap with\n",
            "----------------------------------------------------------------------------------------------------\n",
            "\n",
            "\n",
            "Snippet 7:\n",
            "rtical Facilities as subcomponents to help classify common\n",
            "system architectures that may be used to assemble a complete OMA-centric architecture. It is then the\n",
            "responsibility of the various industries to establish standard architectures that may be leveraged by\n",
            "organizations that operate in these industries. Finally, organizations benefit from being able to leverage\n",
            "foundational, common systems and industry architectures to develop their own proprietary architectures.\n",
            "Based on the models of the various architectures that organizations may use and assuming there exists\n",
            "solutions for them, organizations can develop their own solutions faster by reusing and customizing\n",
            "existing solution components instead of reinventing the wheel. This is actually how the TOGAF solution\n",
            "continuum applies adaptive design reuse.\n",
            "Responsive Web 2.0 Business Solutions\n",
            "World Wide Web Consortium (W3C) is an international community that develops guidelines to ensure the\n",
            "long-term growth and accessibility of the World Wide Web. Web 2.0 is the second generation of the World\n",
            "Wide Web when we shift from static web pages to dynamic content. Web 3.0 is the third generation of the\n",
            "World Wide Web and represents a vision for the future of the Internet characterized by advanced technologies.\n",
            "Most modern websites rely on the Web 2.0 architectural model set forth by W3C. A sample logical application\n",
            "architecture model is illustrated in Figure 2.26.\n",
            "2.3 • Evolving Architectures into Useable Products 75Figure 2.26 The logical application architecture of Microsoft Azure-hosted web applications allows for responsive web and mobile\n",
            "solutions for users. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)\n",
            "In this case, the model leverages the various components available on the Microsoft Azure Cloud. Microsoft\n",
            "Azure is a comprehensive cloud computing platform provided by Microsoft. Azure is designed to help\n",
            "organizations build, deploy, and manage applications and services through a global network of data centers.\n",
            "Azure provides streamlined development capabilities under its DevOps offering to make it very easy to develop\n",
            "and quickly deploy websites on the Azure platform using mainstream web application frameworks (e.g.,\n",
            "ASP.Net, PhP, Java). DevOps is an Agile Software Engineering tools-driven approach that focuses on developing\n",
            "software and deploying it into operation.\n",
            "Many of the support components required to support website implementations are readily available on\n",
            "Microsoft Azure and other systems that provide reusable components for responsible web design. It is easy to\n",
            "evolve the model shown below into a running website. A web application framework has built-in support for\n",
            "architectural patterns that make it easy to extend the framework and use plug-ins to implement commercial\u0002grade websites in a reasonable amount of time. They also support the use of web frameworks that make it\n",
            "possible to build a responsive web application that makes the functionality available on the desktop version of\n",
            "the application seamlessly available on a mobile device. In addition to these capabilities, the adaptive design\n",
            "reuse approach may be used to create the custom part of the web application. More information related to the\n",
            "development of web solutions is provided in Chapter 9 Software Engineering, Chapter 10 Enterprise and\n",
            "Solution Architectures Management, and Chapter 11 Web Applications Development.\n",
            "THINK IT THROUGH\n",
            "Architectural Similarities\n",
            "What is one of the mechanisms that makes it possible to compare architectural similarities between two\n",
            "solutions at different levels?\n",
            "Native Mobile Business Solutions\n",
            "A web application (web app) is a software application that is accessed and interacted with through a web\n",
            "browser over the Internet. Many web-based solutions leverage the inherent capabilities of mobile devices,\n",
            "offering web apps tailored for various types of phones in addition to responsive websites. Numerous\n",
            "frameworks exist to facilitate the development of native web apps, streamlining the process of creating\n",
            "76 2 • Computational Thinking and Design Reusability\n",
            "Access for free at openstax.orgapplications that can run seamlessly on different mobile platforms. These frameworks often provide a unified\n",
            "and efficient approach to building cross-platform mobile applications, ensuring a consistent user experience\n",
            "across various devices.\n",
            "In certain frameworks and development environments, React Native UI component libraries can be leveraged\n",
            "to, port web apps to mobile devices. Examples include React Native support for Android apps using the\n",
            "Android Studio (Android Studio provides a comprehensive environment for developing, testing, and\n",
            "debugging Android apps) or iPhone web app using XCode IDEs (Xcode is an integrated development\n",
            "environment [IDE] developed by Apple for macOS that offers a suite of tools for building software for Apple\n",
            "platforms, including macOS, iOS, watchOS, and tvOS). Figure 2.27 illustrates the logical application architecture\n",
            "of mobile web apps that use React Native. In addition to these capabilities, the adaptive design reuse\n",
            "approach may be used to create the custom part of the native web app. More information related to the\n",
            "development of native web app solutions is provided in Chapter 9 Software Engineering, Chapter 10 Enterprise\n",
            "and Solution Architectures Management, and Chapter 11 Web Applications Development.\n",
            "Figure 2.27 The logical application architecture of React Native mobile web apps shows the back-end processes that allow both\n",
            "Android and IOS customers to use the same application. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)\n",
            "Native Mobile Business Examples\n",
            "Native mobile apps are designed specifically for mobile operating systems, providing optimal performance\n",
            "and a seamless user experience.\n",
            "• WhatsApp: WhatsApp is a native mobile app designed specifically for iOS and Android platforms. It directly\n",
            "accesses the hardware of the device, such as the GPS, camera, and microphone, which allows for features\n",
            "like real-time location sharing, voice and video calls, and media sharing.\n",
            "• Instagram: Instagram is a photo- and video-sharing app. Native development helps Instagram manage\n",
            "high-quality media content efficiently, apply real-time filters, and smoothly handle in-app animations.\n",
            "• Uber Eats: Uber Eats is a food-delivery service that operates as a native app on mobile devices. Being\n",
            "native allows the app to use device-specific features, such as GPS for tracking the delivery person’s\n",
            "location in real time.\n",
            "• Spotify: Spotify uses its native app to deliver personalized music and podcast streaming services. The app’s\n",
            "native nature allows it to integrate closely with the device’s hardw\n",
            "----------------------------------------------------------------------------------------------------\n",
            "\n",
            "\n",
            "Snippet 8:\n",
            "rtical Facilities as subcomponents to help classify common\n",
            "system architectures that may be used to assemble a complete OMA-centric architecture. It is then the\n",
            "responsibility of the various industries to establish standard architectures that may be leveraged by\n",
            "organizations that operate in these industries. Finally, organizations benefit from being able to leverage\n",
            "foundational, common systems and industry architectures to develop their own proprietary architectures.\n",
            "Based on the models of the various architectures that organizations may use and assuming there exists\n",
            "solutions for them, organizations can develop their own solutions faster by reusing and customizing\n",
            "existing solution components instead of reinventing the wheel. This is actually how the TOGAF solution\n",
            "continuum applies adaptive design reuse.\n",
            "Responsive Web 2.0 Business Solutions\n",
            "World Wide Web Consortium (W3C) is an international community that develops guidelines to ensure the\n",
            "long-term growth and accessibility of the World Wide Web. Web 2.0 is the second generation of the World\n",
            "Wide Web when we shift from static web pages to dynamic content. Web 3.0 is the third generation of the\n",
            "World Wide Web and represents a vision for the future of the Internet characterized by advanced technologies.\n",
            "Most modern websites rely on the Web 2.0 architectural model set forth by W3C. A sample logical application\n",
            "architecture model is illustrated in Figure 2.26.\n",
            "2.3 • Evolving Architectures into Useable Products 75Figure 2.26 The logical application architecture of Microsoft Azure-hosted web applications allows for responsive web and mobile\n",
            "solutions for users. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)\n",
            "In this case, the model leverages the various components available on the Microsoft Azure Cloud. Microsoft\n",
            "Azure is a comprehensive cloud computing platform provided by Microsoft. Azure is designed to help\n",
            "organizations build, deploy, and manage applications and services through a global network of data centers.\n",
            "Azure provides streamlined development capabilities under its DevOps offering to make it very easy to develop\n",
            "and quickly deploy websites on the Azure platform using mainstream web application frameworks (e.g.,\n",
            "ASP.Net, PhP, Java). DevOps is an Agile Software Engineering tools-driven approach that focuses on developing\n",
            "software and deploying it into operation.\n",
            "Many of the support components required to support website implementations are readily available on\n",
            "Microsoft Azure and other systems that provide reusable components for responsible web design. It is easy to\n",
            "evolve the model shown below into a running website. A web application framework has built-in support for\n",
            "architectural patterns that make it easy to extend the framework and use plug-ins to implement commercial\u0002grade websites in a reasonable amount of time. They also support the use of web frameworks that make it\n",
            "possible to build a responsive web application that makes the functionality available on the desktop version of\n",
            "the application seamlessly available on a mobile device. In addition to these capabilities, the adaptive design\n",
            "reuse approach may be used to create the custom part of the web application. More information related to the\n",
            "development of web solutions is provided in Chapter 9 Software Engineering, Chapter 10 Enterprise and\n",
            "Solution Architectures Management, and Chapter 11 Web Applications Development.\n",
            "THINK IT THROUGH\n",
            "Architectural Similarities\n",
            "What is one of the mechanisms that makes it possible to compare architectural similarities between two\n",
            "solutions at different levels?\n",
            "Native Mobile Business Solutions\n",
            "A web application (web app) is a software application that is accessed and interacted with through a web\n",
            "browser over the Internet. Many web-based solutions leverage the inherent capabilities of mobile devices,\n",
            "offering web apps tailored for various types of phones in addition to responsive websites. Numerous\n",
            "frameworks exist to facilitate the development of native web apps, streamlining the process of creating\n",
            "76 2 • Computational Thinking and Design Reusability\n",
            "Access for free at openstax.orgapplications that can run seamlessly on different mobile platforms. These frameworks often provide a unified\n",
            "and efficient approach to building cross-platform mobile applications, ensuring a consistent user experience\n",
            "across various devices.\n",
            "In certain frameworks and development environments, React Native UI component libraries can be leveraged\n",
            "to, port web apps to mobile devices. Examples include React Native support for Android apps using the\n",
            "Android Studio (Android Studio provides a comprehensive environment for developing, testing, and\n",
            "debugging Android apps) or iPhone web app using XCode IDEs (Xcode is an integrated development\n",
            "environment [IDE] developed by Apple for macOS that offers a suite of tools for building software for Apple\n",
            "platforms, including macOS, iOS, watchOS, and tvOS). Figure 2.27 illustrates the logical application architecture\n",
            "of mobile web apps that use React Native. In addition to these capabilities, the adaptive design reuse\n",
            "approach may be used to create the custom part of the native web app. More information related to the\n",
            "development of native web app solutions is provided in Chapter 9 Software Engineering, Chapter 10 Enterprise\n",
            "and Solution Architectures Management, and Chapter 11 Web Applications Development.\n",
            "Figure 2.27 The logical application architecture of React Native mobile web apps shows the back-end processes that allow both\n",
            "Android and IOS customers to use the same application. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)\n",
            "Native Mobile Business Examples\n",
            "Native mobile apps are designed specifically for mobile operating systems, providing optimal performance\n",
            "and a seamless user experience.\n",
            "• WhatsApp: WhatsApp is a native mobile app designed specifically for iOS and Android platforms. It directly\n",
            "accesses the hardware of the device, such as the GPS, camera, and microphone, which allows for features\n",
            "like real-time location sharing, voice and video calls, and media sharing.\n",
            "• Instagram: Instagram is a photo- and video-sharing app. Native development helps Instagram manage\n",
            "high-quality media content efficiently, apply real-time filters, and smoothly handle in-app animations.\n",
            "• Uber Eats: Uber Eats is a food-delivery service that operates as a native app on mobile devices. Being\n",
            "native allows the app to use device-specific features, such as GPS for tracking the delivery person’s\n",
            "location in real time.\n",
            "• Spotify: Spotify uses its native app to deliver personalized music and podcast streaming services. The app’s\n",
            "native nature allows it to integrate closely with the device’s hardw\n",
            "----------------------------------------------------------------------------------------------------\n",
            "\n",
            "\n",
            "Snippet 9:\n",
            "t Services, Horizontal Facilities, and Vertical Facilities as subcomponents to help classify common\n",
            "system architectures that may be used to assemble a complete OMA-centric architecture. It is then the\n",
            "responsibility of the various industries to establish standard architectures that may be leveraged by\n",
            "organizations that operate in these industries. Finally, organizations benefit from being able to leverage\n",
            "foundational, common systems and industry architectures to develop their own proprietary architectures.\n",
            "Based on the models of the various architectures that organizations may use and assuming there exists\n",
            "solutions for them, organizations can develop their own solutions faster by reusing and customizing\n",
            "existing solution components instead of reinventing the wheel. This is actually how the TOGAF solution\n",
            "continuum applies adaptive design reuse.\n",
            "Responsive Web 2.0 Business Solutions\n",
            "World Wide Web Consortium (W3C)is an international community that develops guidelines to ensure the\n",
            "long-term growth and accessibility of the World Wide Web. Web 2.0is the second generation of the World\n",
            "Wide Web when we shift from static web pages to dynamic content. Web 3.0is the third generation of the\n",
            "World Wide Web and represents a vision for the future of the Internet characterized by advanced technologies.\n",
            "Most modern websites rely on the Web 2.0 architectural model set forth by W3C. A sample logical application\n",
            "architecture model is illustrated in Figure 2.26.\n",
            "2.3 • Evolving Architectures into Useable Products 75Figure2.26 The logical application architecture of Microsoft Azure-hosted web applications allows for responsive web and mobile\n",
            "solutions for users. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)\n",
            "In this case, the model leverages the various components available on the Microsoft Azure Cloud. Microsoft\n",
            "Azureis a comprehensive cloud computing platform provided by Microsoft. Azure is designed to help\n",
            "organizations build, deploy, and manage applications and services through a global network of data centers.\n",
            "Azure provides streamlined development capabilities under its DevOps offering to make it very easy to develop\n",
            "and quickly deploy websites on the Azure platform using mainstream web application frameworks (e.g.,\n",
            "ASP.Net, PhP, Java). DevOps is an Agile Software Engineering tools-driven approach that focuses on developing\n",
            "software and deploying it into operation.\n",
            "Many of the support components required to support website implementations are readily available on\n",
            "Microsoft Azure and other systems that provide reusable components for responsible web design. It is easy to\n",
            "evolve the model shown below into a running website. A web application frameworkhas built-in support for\n",
            "architectural patterns that make it easy to extend the framework and use plug-ins to implement commercial-\n",
            "grade websites in a reasonable amount of time. They also support the use of web frameworks that make it\n",
            "possible to build a responsive web application that makes the functionality available on the desktop version of\n",
            "the application seamlessly available on a mobile device. In addition to these capabilities, the adaptive design\n",
            "reuse approach may be used to create the custom part of the web application. More information related to the\n",
            "development of web solutions is provided in Chapter 9 Software Engineering, Chapter 10 Enterprise and\n",
            "Solution Architectures Management, and Chapter 11 Web Applications Development.\n",
            "THINK IT THROUGH\n",
            "Architectural Similarities\n",
            "What is one of the mechanisms that makes it possible to compare architectural similarities between two\n",
            "solutions at different levels?\n",
            "Native Mobile Business Solutions\n",
            "A web application (web app)is a software application that is accessed and interacted with through a web\n",
            "browser over the Internet. Many web-based solutions leverage the inherent capabilities of mobile devices,\n",
            "offering web apps tailored for various types of phones in addition to responsive websites. Numerous\n",
            "frameworks exist to facilitate the development of native web apps, streamlining the process of creating\n",
            "76 2 • Computational Thinking and Design Reusability\n",
            "Access for free at openstax.orgapplications that can run seamlessly on different mobile platforms. These frameworks often provide a unified\n",
            "and efficient approach to building cross-platform mobile applications, ensuring a consistent user experience\n",
            "across various devices.\n",
            "In certain frameworks and development environments, React Native UI component libraries can be leveraged\n",
            "to, port web apps to mobile devices. Examples include React Native support for Android apps using the\n",
            "Android Studio (Android Studio provides a comprehensive environment for developing, testing, and\n",
            "debugging Android apps) or iPhone web app using XCode IDEs (Xcode is an integrated development\n",
            "environment [IDE] developed by Apple for macOS that offers a suite of tools for building software for Apple\n",
            "platforms, including macOS, iOS, watchOS, and tvOS). Figure 2.27 illustrates the logical application architecture\n",
            "of mobile web apps that use React Native. In addition to these capabilities, the adaptive design reuse\n",
            "approach may be used to create the custom part of the native web app. More information related to the\n",
            "development of native web app solutions is provided in Chapter 9 Software Engineering, Chapter 10 Enterprise\n",
            "and Solution Architectures Management, and Chapter 11 Web Applications Development.\n",
            "Figure2.27 The logical application architecture of React Native mobile web apps shows the back-end processes that allow both\n",
            "Android and IOS customers to use the same application. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)\n",
            "Native Mobile Business Examples\n",
            "Native mobile apps are designed specifically for mobile operating systems, providing optimal performance\n",
            "and a seamless user experience.\n",
            "• WhatsApp: WhatsApp is a native mobile app designed specifically for iOS and Android platforms. It directly\n",
            "accesses the hardware of the device, such as the GPS, camera, and microphone, which allows for features\n",
            "like real-time location sharing, voice and video calls, and media sharing.\n",
            "• Instagram: Instagram is a photo- and video-sharing app. Native development helps Instagram manage\n",
            "high-quality media content efficiently, apply real-time filters, and smoothly handle in-app animations.\n",
            "• Uber Eats: Uber Eats is a food-delivery service that operates as a native app on mobile devices. Being\n",
            "native allows the app to use device-specific features, such as GPS for tracking the delivery person’s\n",
            "location in real time.\n",
            "• Spotify: Spotify uses its native app to deliver personalized music and podcast streaming services. The app’s\n",
            "native nature allows it to integrate closely with the device’s hardware, offering features like offline\n",
            "d\n",
            "----------------------------------------------------------------------------------------------------\n",
            "\n",
            "\n",
            "Snippet 10:\n",
            "itecture scope is the extent and\n",
            "boundaries within which architectural considerations, decisions, and solutions apply.\n",
            "Figure 2.23 TOGAF architectural dimensions include various levels of abstraction. (attribution: Copyright Rice University, OpenStax,\n",
            "under CC BY 4.0 license)\n",
            "Portfolio- or domain-level architectures usually concentrate on collections of solutions and projects associated\n",
            "with a specific business unit, like marketing or sales in a large organization. In contrast, project- or system\u0002level architecture is geared toward individual solutions and projects within those business units. Defining the\n",
            "72 2 • Computational Thinking and Design Reusability\n",
            "Access for free at openstax.orgscope of a model is crucial because there exists a direct relationship between the scope and the level of detail\n",
            "achievable in a blueprint. This is due to the necessity for increased generalization, such as simplification,\n",
            "feature selection, and grouping, as the blueprint’s scope expands.\n",
            "TECHNOLOGY IN EVERYDAY LIFE\n",
            "Adaptive Design Reuse: Eco-Friendly Homes from Recycled Materials\n",
            "Adaptive design reuse can significantly benefit people in everyday life by promoting efficiency,\n",
            "sustainability, and improved user experiences. Imagine a neighborhood called EcoHomes, where all the\n",
            "houses are built using old materials from buildings that were taken down or left unused. It is all about\n",
            "making new homes without needing to produce or buy more materials, which helps the environment. In\n",
            "EcoHomes, architects and builders take things like bricks, glass, and wood from old sites and use them to\n",
            "build new, modern houses. For example, wooden beams from an old barn become part of the living room\n",
            "in a new house, adding a cool, old-time feel to a modern design. Windows from an old office building let in\n",
            "lots of sunlight, cutting down on the need for electric lights. EcoHomes is a hit because it shows how\n",
            "reusing building materials can save money and help the planet. The people living there have lower energy\n",
            "bills and are proud of their unique, eco-friendly homes. This story shows how using what we already have in\n",
            "new ways can make a big difference for our wallets and the world.\n",
            "2.3 Evolving Architectures into Useable Products\n",
            "Learning Objectives\n",
            "By the end of this section, you will be able to:\n",
            "• Analyze similarities between architectures and apply patterns\n",
            "• Discuss how to accelerate the creation of applications\n",
            "The combination of top-down, adaptive design reuse, and bottom-up, computational thinking, optimizes\n",
            "modern software development. This blend allows software developers to find a middle ground by adapting\n",
            "and assembling existing components, minimizing the need for developing entirely new software. A clear\n",
            "example of this cooperation is evident in modern websites, where the Model-View-Controller architectural\n",
            "pattern is widely employed. The Model-View-Controller (MVC) is a software architectural pattern commonly\n",
            "used in the design of interactive applications, providing a systematic way to organize and structure code. The\n",
            "pattern separates an application into three interconnected components: model, view, and controller. The\n",
            "model represents the application’s data structure and business logic, managing data and rules. The view is\n",
            "responsible for displaying the user interface; it shows data to the user and sends user commands to the\n",
            "controller. The controller serves as an intermediary between the model and the view. It processes user input\n",
            "received from the view, interacts with the model to retrieve or update data, and determines the appropriate\n",
            "view for presenting the response. Many practical web application frameworks, such as Django, have already\n",
            "implemented the MVC pattern. In this setup, the application is divided into three parts: the model handles the\n",
            "data structure, the view displays the data on web pages, and the controller manages the business logic,\n",
            "facilitating interaction between the model and the view. Adding a broker pattern to MVC architectures can\n",
            "improve the system’s scalability and flexibility when applicable and/or necessary. The broker acts as a\n",
            "middleman that manages communication between different parts of the application, helping to handle more\n",
            "data and complex operations efficiently.\n",
            "Leveraging these existing frameworks enables developers to concentrate on crafting the specific logic relevant\n",
            "to the website rather than reinventing the wheel. The beauty of this approach lies in the ability to swiftly piece\n",
            "together solutions by extending and adapting the available frameworks. By doing so, developers streamline\n",
            "the development process, enhance efficiency, and capitalize on the collective wisdom embedded in proven\n",
            "2.3 • Evolving Architectures into Useable Products 73frameworks, thereby fostering innovation in a more focused and resource-efficient manner.\n",
            "Leveraging Architectural Similarities and Applying Patterns\n",
            "The adaptive design reuse approach is a strategy in software development that emphasizes the efficient reuse\n",
            "of existing design solutions to create new systems or applications. The beauty of the adaptive design reuse\n",
            "approach is that the business solution architecture model helps create abstract representations of real\n",
            "systems. Therefore, if there exist tangible realizations of the various components that are part of these\n",
            "abstract representations, it is possible to implement the model and create specialized running business\n",
            "solutions from it.\n",
            "A solutions continuum is a strategy where existing solutions, components, or patterns are leveraged and\n",
            "adapted for use in different contexts. Figure 2.24 illustrates the TOGAF model of reuse that is referred to as the\n",
            "solutions continuum. As mentioned earlier, TOGAF does not provide a prescriptive approach to creating and/or\n",
            "managing a catalog of patterns. However, various pattern repositories are available on the Internet and the\n",
            "adaptive design technique can be used to avoid having to reinvent the wheel when architectural patterns and\n",
            "related component implementations exist and can be customized and assembled with new components. More\n",
            "information on this topic is provided in Chapter 10 Enterprise and Solution Architectures Management.\n",
            "Figure 2.24 This TOGAF solutions continuum illustrates how each architecture guides and supports the others. (attribution:\n",
            "Copyright Rice University, OpenStax, under CC BY 4.0 license)\n",
            "As illustrated in Figure 2.25, the TOGAF solutions continuum offers a limited set of dimensions. It serves as a\n",
            "guideline, and The Open Group allows interested parties to enhance the model by incorporating additional\n",
            "dimensions that are relevant to their specific needs.\n",
            "74 2 • Computational Thinking and Design Reusability\n",
            "Access for free at openstax.org\n",
            "----------------------------------------------------------------------------------------------------\n",
            "\n",
            "\n",
            "Snippet 11:\n",
            "itecture scope is the extent and\n",
            "boundaries within which architectural considerations, decisions, and solutions apply.\n",
            "Figure 2.23 TOGAF architectural dimensions include various levels of abstraction. (attribution: Copyright Rice University, OpenStax,\n",
            "under CC BY 4.0 license)\n",
            "Portfolio- or domain-level architectures usually concentrate on collections of solutions and projects associated\n",
            "with a specific business unit, like marketing or sales in a large organization. In contrast, project- or system\u0002level architecture is geared toward individual solutions and projects within those business units. Defining the\n",
            "72 2 • Computational Thinking and Design Reusability\n",
            "Access for free at openstax.orgscope of a model is crucial because there exists a direct relationship between the scope and the level of detail\n",
            "achievable in a blueprint. This is due to the necessity for increased generalization, such as simplification,\n",
            "feature selection, and grouping, as the blueprint’s scope expands.\n",
            "TECHNOLOGY IN EVERYDAY LIFE\n",
            "Adaptive Design Reuse: Eco-Friendly Homes from Recycled Materials\n",
            "Adaptive design reuse can significantly benefit people in everyday life by promoting efficiency,\n",
            "sustainability, and improved user experiences. Imagine a neighborhood called EcoHomes, where all the\n",
            "houses are built using old materials from buildings that were taken down or left unused. It is all about\n",
            "making new homes without needing to produce or buy more materials, which helps the environment. In\n",
            "EcoHomes, architects and builders take things like bricks, glass, and wood from old sites and use them to\n",
            "build new, modern houses. For example, wooden beams from an old barn become part of the living room\n",
            "in a new house, adding a cool, old-time feel to a modern design. Windows from an old office building let in\n",
            "lots of sunlight, cutting down on the need for electric lights. EcoHomes is a hit because it shows how\n",
            "reusing building materials can save money and help the planet. The people living there have lower energy\n",
            "bills and are proud of their unique, eco-friendly homes. This story shows how using what we already have in\n",
            "new ways can make a big difference for our wallets and the world.\n",
            "2.3 Evolving Architectures into Useable Products\n",
            "Learning Objectives\n",
            "By the end of this section, you will be able to:\n",
            "• Analyze similarities between architectures and apply patterns\n",
            "• Discuss how to accelerate the creation of applications\n",
            "The combination of top-down, adaptive design reuse, and bottom-up, computational thinking, optimizes\n",
            "modern software development. This blend allows software developers to find a middle ground by adapting\n",
            "and assembling existing components, minimizing the need for developing entirely new software. A clear\n",
            "example of this cooperation is evident in modern websites, where the Model-View-Controller architectural\n",
            "pattern is widely employed. The Model-View-Controller (MVC) is a software architectural pattern commonly\n",
            "used in the design of interactive applications, providing a systematic way to organize and structure code. The\n",
            "pattern separates an application into three interconnected components: model, view, and controller. The\n",
            "model represents the application’s data structure and business logic, managing data and rules. The view is\n",
            "responsible for displaying the user interface; it shows data to the user and sends user commands to the\n",
            "controller. The controller serves as an intermediary between the model and the view. It processes user input\n",
            "received from the view, interacts with the model to retrieve or update data, and determines the appropriate\n",
            "view for presenting the response. Many practical web application frameworks, such as Django, have already\n",
            "implemented the MVC pattern. In this setup, the application is divided into three parts: the model handles the\n",
            "data structure, the view displays the data on web pages, and the controller manages the business logic,\n",
            "facilitating interaction between the model and the view. Adding a broker pattern to MVC architectures can\n",
            "improve the system’s scalability and flexibility when applicable and/or necessary. The broker acts as a\n",
            "middleman that manages communication between different parts of the application, helping to handle more\n",
            "data and complex operations efficiently.\n",
            "Leveraging these existing frameworks enables developers to concentrate on crafting the specific logic relevant\n",
            "to the website rather than reinventing the wheel. The beauty of this approach lies in the ability to swiftly piece\n",
            "together solutions by extending and adapting the available frameworks. By doing so, developers streamline\n",
            "the development process, enhance efficiency, and capitalize on the collective wisdom embedded in proven\n",
            "2.3 • Evolving Architectures into Useable Products 73frameworks, thereby fostering innovation in a more focused and resource-efficient manner.\n",
            "Leveraging Architectural Similarities and Applying Patterns\n",
            "The adaptive design reuse approach is a strategy in software development that emphasizes the efficient reuse\n",
            "of existing design solutions to create new systems or applications. The beauty of the adaptive design reuse\n",
            "approach is that the business solution architecture model helps create abstract representations of real\n",
            "systems. Therefore, if there exist tangible realizations of the various components that are part of these\n",
            "abstract representations, it is possible to implement the model and create specialized running business\n",
            "solutions from it.\n",
            "A solutions continuum is a strategy where existing solutions, components, or patterns are leveraged and\n",
            "adapted for use in different contexts. Figure 2.24 illustrates the TOGAF model of reuse that is referred to as the\n",
            "solutions continuum. As mentioned earlier, TOGAF does not provide a prescriptive approach to creating and/or\n",
            "managing a catalog of patterns. However, various pattern repositories are available on the Internet and the\n",
            "adaptive design technique can be used to avoid having to reinvent the wheel when architectural patterns and\n",
            "related component implementations exist and can be customized and assembled with new components. More\n",
            "information on this topic is provided in Chapter 10 Enterprise and Solution Architectures Management.\n",
            "Figure 2.24 This TOGAF solutions continuum illustrates how each architecture guides and supports the others. (attribution:\n",
            "Copyright Rice University, OpenStax, under CC BY 4.0 license)\n",
            "As illustrated in Figure 2.25, the TOGAF solutions continuum offers a limited set of dimensions. It serves as a\n",
            "guideline, and The Open Group allows interested parties to enhance the model by incorporating additional\n",
            "dimensions that are relevant to their specific needs.\n",
            "74 2 • Computational Thinking and Design Reusability\n",
            "Access for free at openstax.org\n",
            "----------------------------------------------------------------------------------------------------\n",
            "\n",
            "\n",
            "Snippet 12:\n",
            " Engineering and Chapter 10 Enterprise and Solution Architectures\n",
            "Management, architectural styles, architectural patterns, and design patterns are typically used to enforce\n",
            "the quality attributes of software solutions. To facilitate the creation and maintenance of web applications\n",
            "and scalable transactional websites, web application frameworks and native application frameworks that\n",
            "leverage applicable patterns, such as MVC, were created and improved over the past couple of decades.\n",
            "Web frameworks are used within web application frameworks to facilitate the use of HTML5, CSS3, and\n",
            "JavaScript and to publish responsive web pages that can be rendered by modern browsers on all modern\n",
            "target devices. Web application frameworks help process UI-driven requests that result in publishing or\n",
            "updating web pages. Native application frameworks take advantage of capabilities available on specific\n",
            "target devices such as iPhones and Android phones. Organizations in many industries rely on web\n",
            "applications and related frameworks to conduct business daily.\n",
            "Web 3.0 Applications\n",
            "Web 3.0 is the next phase of the Web. It is still being realized, and similar to Web 1.0 and 2.0, it can only be\n",
            "fully understood in hindsight. The technology and uses of the Web overlap between the phases, with newer\n",
            "phases becoming preferred over their predecessor phases. If Web 1.0 was the read-only web, and Web 2.0 was\n",
            "the participation (write) web, then Web 3.0 may be the read, write, and execute web.\n",
            "Tim Berners-Lee had referred to Web 3.0 as the Semantic Web, a system of autonomous agents, which are\n",
            "software programs that respond to events. That model has shifted over the years. While AI (and other\n",
            "technologies such as AR/VR) will likely form a part of Web 3.0 or Web x.0, the principles that govern the next\n",
            "phase are expected to be around a web that is decentralized, permissionless, and trusted.\n",
            "Web 3.0 sees a shift from the more traditional client-server model to a peer-to-peer networking model. A peer\u0002to-peer network is one in which devices connect and can share data and processing without needing a\n",
            "centralized server. Peers in this scheme can perform the role of a traditional client, server, or both. This shift\n",
            "will foster a trusted, decentralized, and open web, where large companies don’t own the data, but everyone\n",
            "collectively owns it. Technologies such as a smart contract allow a trusted model that is needed in a\n",
            "decentralized system. Artificial intelligence and machine learning will improve information access through\n",
            "understanding the meaning of content available on the Web. The exemplar apps of the Web 3.0 phase will be\n",
            "defined in the future. Still, if the previous phases of the Web are any indication, it will fundamentally change\n",
            "how we operate in an ever-evolving technological world.\n",
            "Finally, Web 3.0 apps will run on a web that supports Web 1.0 and 2.0 apps, with the likely result being hybrid\n",
            "architectures that are partially Web 2.0 and 3.0.\n",
            "Web 3.0 Application Architectures\n",
            "Web 3.0 apps are architected without a centralized server, so they are considered to be decentralized Apps\n",
            "(DApps), which are applications that execute smart contracts and run over distributed ledger technology (DLT).\n",
            "Smart contracts are programs that can be executed on a distributed ledger. Distributed ledgers use\n",
            "independent network nodes to record, share, and synchronize transactions in their respective electronic\n",
            "ledgers instead of keeping them in a centralized server. The code is visible to all parties, and trust is put into\n",
            "the code instead of a centralized third party. Distributed ledgers chronicle transactions between accounts that\n",
            "are recorded in multiple places. Blockchain is a type of DLT.\n",
            "Let’s compare a traditional Web 2.0 application with a 3.0 DApp. In Web 2.0, if you created a website for users\n",
            "to post pictures and make comments on them, you would need functionality for authenticating users,\n",
            "576 11 • Web Applications Development\n",
            "Access for free at openstax.orgauthorizing their actions, generating a UI for adding images, browsing images, and posting comments. To do\n",
            "this, you would need a front-end web server and back-end processing for business logic and data storage.\n",
            "These servers would run in a company’s data center or on a cloud provider. The company would own all the\n",
            "code and data, including metadata about how you interact with the website (e.g., what you commented on,\n",
            "how long you looked at a picture). As a reminder, Figure 11.4 illustrates a traditional Web 2.0 architecture (note:\n",
            "for our purposes, the SPA architecture could also be used here).\n",
            "In a Web 3.0 DApp, the functionality for creating an application for posting pictures and commenting on them\n",
            "would remain the same. The principal differences would be where the code runs and who owns the code and\n",
            "data. Let’s break this down into a series of steps that shift away from a centralized solution to a distributed\n",
            "one.\n",
            "To start, we can keep the web server’s front end and replace the back-end code with the distributed\n",
            "application. The Ethereum blockchain, as an example, is a deterministic state machine that runs on a peer-to\u0002peer network. A deterministic state machine has a model of computation that relies on a finite number of\n",
            "states and transitions between them to respond to inputs. It guarantees a single transition from one state to\n",
            "another in response to an input. Because it is based on a deterministic state machine, the Ethereum\n",
            "blockchain is often referred to as a “world computer.” Ethereum blockchain transactions are calls to methods\n",
            "that are implemented in smart contracts. These method calls result in change to the data (aka, state) that is\n",
            "maintained by the contracts within the blockchain. The Ethereum blockchain records transactions into blocks\n",
            "that are added to its blockchain. Changes to the state machine itself (e.g., modify the block or transaction data\n",
            "structures used in the Ethereum blockchain) require consensus between the node providers that support the\n",
            "peer-to-peer blockchain network. Anyone in the world can read or write to the machine—a central authority\n",
            "does not govern it.\n",
            "Smart contracts form the code and are written in high-level languages like Solidity or Vyper. The high-level\n",
            "contract code is compiled into bytecode that can be executed on the Ethereum Virtual Machine (EVM). Each\n",
            "block contains a hash pointer of the previous block, with a time stamp and the transaction data. The hash\n",
            "pointer includes a cryptographic hash (i.e., a fixed-size digest of the previous block that makes it possible to\n",
            "verify that the previous block was not changed since it was stored in the blockchain; the cryptographic part\n",
            "ensures that the hash value has some special properties and, in partic\n",
            "----------------------------------------------------------------------------------------------------\n",
            "\n",
            "\n",
            "Snippet 13:\n",
            " Engineering and Chapter 10 Enterprise and Solution Architectures\n",
            "Management, architectural styles, architectural patterns, and design patterns are typically used to enforce\n",
            "the quality attributes of software solutions. To facilitate the creation and maintenance of web applications\n",
            "and scalable transactional websites, web application frameworks and native application frameworks that\n",
            "leverage applicable patterns, such as MVC, were created and improved over the past couple of decades.\n",
            "Web frameworks are used within web application frameworks to facilitate the use of HTML5, CSS3, and\n",
            "JavaScript and to publish responsive web pages that can be rendered by modern browsers on all modern\n",
            "target devices. Web application frameworks help process UI-driven requests that result in publishing or\n",
            "updating web pages. Native application frameworks take advantage of capabilities available on specific\n",
            "target devices such as iPhones and Android phones. Organizations in many industries rely on web\n",
            "applications and related frameworks to conduct business daily.\n",
            "Web 3.0 Applications\n",
            "Web 3.0 is the next phase of the Web. It is still being realized, and similar to Web 1.0 and 2.0, it can only be\n",
            "fully understood in hindsight. The technology and uses of the Web overlap between the phases, with newer\n",
            "phases becoming preferred over their predecessor phases. If Web 1.0 was the read-only web, and Web 2.0 was\n",
            "the participation (write) web, then Web 3.0 may be the read, write, and execute web.\n",
            "Tim Berners-Lee had referred to Web 3.0 as the Semantic Web, a system of autonomous agents, which are\n",
            "software programs that respond to events. That model has shifted over the years. While AI (and other\n",
            "technologies such as AR/VR) will likely form a part of Web 3.0 or Web x.0, the principles that govern the next\n",
            "phase are expected to be around a web that is decentralized, permissionless, and trusted.\n",
            "Web 3.0 sees a shift from the more traditional client-server model to a peer-to-peer networking model. A peer\u0002to-peer network is one in which devices connect and can share data and processing without needing a\n",
            "centralized server. Peers in this scheme can perform the role of a traditional client, server, or both. This shift\n",
            "will foster a trusted, decentralized, and open web, where large companies don’t own the data, but everyone\n",
            "collectively owns it. Technologies such as a smart contract allow a trusted model that is needed in a\n",
            "decentralized system. Artificial intelligence and machine learning will improve information access through\n",
            "understanding the meaning of content available on the Web. The exemplar apps of the Web 3.0 phase will be\n",
            "defined in the future. Still, if the previous phases of the Web are any indication, it will fundamentally change\n",
            "how we operate in an ever-evolving technological world.\n",
            "Finally, Web 3.0 apps will run on a web that supports Web 1.0 and 2.0 apps, with the likely result being hybrid\n",
            "architectures that are partially Web 2.0 and 3.0.\n",
            "Web 3.0 Application Architectures\n",
            "Web 3.0 apps are architected without a centralized server, so they are considered to be decentralized Apps\n",
            "(DApps), which are applications that execute smart contracts and run over distributed ledger technology (DLT).\n",
            "Smart contracts are programs that can be executed on a distributed ledger. Distributed ledgers use\n",
            "independent network nodes to record, share, and synchronize transactions in their respective electronic\n",
            "ledgers instead of keeping them in a centralized server. The code is visible to all parties, and trust is put into\n",
            "the code instead of a centralized third party. Distributed ledgers chronicle transactions between accounts that\n",
            "are recorded in multiple places. Blockchain is a type of DLT.\n",
            "Let’s compare a traditional Web 2.0 application with a 3.0 DApp. In Web 2.0, if you created a website for users\n",
            "to post pictures and make comments on them, you would need functionality for authenticating users,\n",
            "576 11 • Web Applications Development\n",
            "Access for free at openstax.orgauthorizing their actions, generating a UI for adding images, browsing images, and posting comments. To do\n",
            "this, you would need a front-end web server and back-end processing for business logic and data storage.\n",
            "These servers would run in a company’s data center or on a cloud provider. The company would own all the\n",
            "code and data, including metadata about how you interact with the website (e.g., what you commented on,\n",
            "how long you looked at a picture). As a reminder, Figure 11.4 illustrates a traditional Web 2.0 architecture (note:\n",
            "for our purposes, the SPA architecture could also be used here).\n",
            "In a Web 3.0 DApp, the functionality for creating an application for posting pictures and commenting on them\n",
            "would remain the same. The principal differences would be where the code runs and who owns the code and\n",
            "data. Let’s break this down into a series of steps that shift away from a centralized solution to a distributed\n",
            "one.\n",
            "To start, we can keep the web server’s front end and replace the back-end code with the distributed\n",
            "application. The Ethereum blockchain, as an example, is a deterministic state machine that runs on a peer-to\u0002peer network. A deterministic state machine has a model of computation that relies on a finite number of\n",
            "states and transitions between them to respond to inputs. It guarantees a single transition from one state to\n",
            "another in response to an input. Because it is based on a deterministic state machine, the Ethereum\n",
            "blockchain is often referred to as a “world computer.” Ethereum blockchain transactions are calls to methods\n",
            "that are implemented in smart contracts. These method calls result in change to the data (aka, state) that is\n",
            "maintained by the contracts within the blockchain. The Ethereum blockchain records transactions into blocks\n",
            "that are added to its blockchain. Changes to the state machine itself (e.g., modify the block or transaction data\n",
            "structures used in the Ethereum blockchain) require consensus between the node providers that support the\n",
            "peer-to-peer blockchain network. Anyone in the world can read or write to the machine—a central authority\n",
            "does not govern it.\n",
            "Smart contracts form the code and are written in high-level languages like Solidity or Vyper. The high-level\n",
            "contract code is compiled into bytecode that can be executed on the Ethereum Virtual Machine (EVM). Each\n",
            "block contains a hash pointer of the previous block, with a time stamp and the transaction data. The hash\n",
            "pointer includes a cryptographic hash (i.e., a fixed-size digest of the previous block that makes it possible to\n",
            "verify that the previous block was not changed since it was stored in the blockchain; the cryptographic part\n",
            "ensures that the hash value has some special properties and, in partic\n",
            "----------------------------------------------------------------------------------------------------\n",
            "\n",
            "\n",
            "Snippet 14:\n",
            "s discussed in Chapter 9 Software Engineering and Chapter 10 Enterprise and Solution Architectures\n",
            "Management, architectural styles, architectural patterns, and design patterns are typically used to enforce\n",
            "the quality attributes of software solutions. To facilitate the creation and maintenance of web applications\n",
            "and scalable transactional websites, web application frameworks and native application frameworks that\n",
            "leverage applicable patterns, such as MVC, were created and improved over the past couple of decades.\n",
            "Web frameworks are used within web application frameworks to facilitate the use of HTML5, CSS3, and\n",
            "JavaScript and to publish responsive web pages that can be rendered by modern browsers on all modern\n",
            "target devices. Web application frameworks help process UI-driven requests that result in publishing or\n",
            "updating web pages. Native application frameworks take advantage of capabilities available on specific\n",
            "target devices such as iPhones and Android phones. Organizations in many industries rely on web\n",
            "applications and related frameworks to conduct business daily.\n",
            "Web 3.0 Applications\n",
            "Web 3.0 is the next phase of the Web. It is still being realized, and similar to Web 1.0 and 2.0, it can only be\n",
            "fully understood in hindsight. The technology and uses of the Web overlap between the phases, with newer\n",
            "phases becoming preferred over their predecessor phases. If Web 1.0 was the read-only web, and Web 2.0 was\n",
            "the participation (write) web, then Web 3.0 may be the read, write, and execute web.\n",
            "Tim Berners-Lee had referred to Web 3.0 as the Semantic Web, a system of autonomous agents, which are\n",
            "software programs that respond to events. That model has shifted over the years. While AI (and other\n",
            "technologies such as AR/VR) will likely form a part of Web 3.0 or Web x.0, the principles that govern the next\n",
            "phase are expected to be around a web that is decentralized, permissionless, and trusted.\n",
            "Web 3.0 sees a shift from the more traditional client-server model to a peer-to-peer networking model. A peer-\n",
            "to-peer network is one in which devices connect and can share data and processing without needing a\n",
            "centralized server. Peers in this scheme can perform the role of a traditional client, server, or both. This shift\n",
            "will foster a trusted, decentralized, and open web, where large companies don’t own the data, but everyone\n",
            "collectively owns it. Technologies such as a smart contract allow a trusted model that is needed in a\n",
            "decentralized system. Artificial intelligence and machine learning will improve information access through\n",
            "understanding the meaning of content available on the Web. The exemplar apps of the Web 3.0 phase will be\n",
            "defined in the future. Still, if the previous phases of the Web are any indication, it will fundamentally change\n",
            "how we operate in an ever-evolving technological world.\n",
            "Finally, Web 3.0 apps will run on a web that supports Web 1.0 and 2.0 apps, with the likely result being hybrid\n",
            "architectures that are partially Web 2.0 and 3.0.\n",
            "Web 3.0 Application Architectures\n",
            "Web 3.0 apps are architected without a centralized server, so they are considered to be decentralized Apps\n",
            "(DApps), which are applications that execute smart contracts and run over distributed ledger technology (DLT).\n",
            "Smart contracts are programs that can be executed on a distributed ledger. Distributed ledgers use\n",
            "independent network nodes to record, share, and synchronize transactions in their respective electronic\n",
            "ledgers instead of keeping them in a centralized server. The code is visible to all parties, and trust is put into\n",
            "the code instead of a centralized third party. Distributed ledgers chronicle transactions between accounts that\n",
            "are recorded in multiple places. Blockchain is a type of DLT.\n",
            "Let’s compare a traditional Web 2.0 application with a 3.0 DApp. In Web 2.0, if you created a website for users\n",
            "to post pictures and make comments on them, you would need functionality for authenticating users,\n",
            "576 11 • Web Applications Development\n",
            "Access for free at openstax.orgauthorizing their actions, generating a UI for adding images, browsing images, and posting comments. To do\n",
            "this, you would need a front-end web server and back-end processing for business logic and data storage.\n",
            "These servers would run in a company’s data center or on a cloud provider. The company would own all the\n",
            "code and data, including metadata about how you interact with the website (e.g., what you commented on,\n",
            "how long you looked at a picture). As a reminder, Figure 11.4 illustrates a traditional Web 2.0 architecture (note:\n",
            "for our purposes, the SPA architecture could also be used here).\n",
            "In a Web 3.0 DApp, the functionality for creating an application for posting pictures and commenting on them\n",
            "would remain the same. The principal differences would be where the code runs and who owns the code and\n",
            "data. Let’s break this down into a series of steps that shift away from a centralized solution to a distributed\n",
            "one.\n",
            "To start, we can keep the web server’s front end and replace the back-end code with the distributed\n",
            "application. The Ethereum blockchain, as an example, is a deterministic state machine that runs on a peer-to-\n",
            "peer network. A deterministic state machine has a model of computation that relies on a finite number of\n",
            "states and transitions between them to respond to inputs. It guarantees a single transition from one state to\n",
            "another in response to an input. Because it is based on a deterministic state machine, the Ethereum\n",
            "blockchain is often referred to as a “world computer.” Ethereum blockchain transactions are calls to methods\n",
            "that are implemented in smart contracts. These method calls result in change to the data (aka, state) that is\n",
            "maintained by the contracts within the blockchain. The Ethereum blockchain records transactions into blocks\n",
            "that are added to its blockchain. Changes to the state machine itself (e.g., modify the block or transaction data\n",
            "structures used in the Ethereum blockchain) require consensus between the node providers that support the\n",
            "peer-to-peer blockchain network. Anyone in the world can read or write to the machine—a centr al authority\n",
            "does not govern it.\n",
            "Smart contracts form the code and are written in high-level languages like Solidity or Vyper. The high-level\n",
            "contract code is compiled into bytecode that can be executed on the Ethereum Virtual Machine (EVM). Each\n",
            "block contains a hash pointer of the previous block, with a time stamp and the transaction data. The hash\n",
            "pointer includes a cryptographic hash (i.e., a fixed-size digest of the previous block that makes it possible to\n",
            "verify that the previous block was not changed since it was stored in the blockchain; the cryptographic part\n",
            "ensures that the hash value has some special properties and, in particular, that the original data ca\n",
            "----------------------------------------------------------------------------------------------------\n",
            "\n",
            "\n",
            "Snippet 15:\n",
            "h of applicability at the enterprise, portfolio, or project level. The architecture scopeis the extent and\n",
            "boundaries within which architectural considerations, decisions, and solutions apply.\n",
            "Figure2.23 TOGAF architectural dimensions include various levels of abstraction. (attribution: Copyright Rice University, OpenStax,\n",
            "under CC BY 4.0 license)\n",
            "Portfolio- or domain-level architectures usually concentrate on collections of solutions and projects associated\n",
            "with a specific business unit, like marketing or sales in a large organization. In contrast, project- or system-\n",
            "level architecture is geared toward individual solutions and projects within those business units. Defining the\n",
            "72 2 • Computational Thinking and Design Reusability\n",
            "Access for free at openstax.orgscope of a model is crucial because there exists a direct relationship between the scope and the level of detail\n",
            "achievable in a blueprint. This is due to the necessity for increased generalization, such as simplification,\n",
            "feature selection, and grouping, as the blueprint’s scope expands.\n",
            "TECHNOLOGY IN EVERYDAY LIFE\n",
            "Adaptive Design Reuse: Eco-Friendly Homes from Recycled Materials\n",
            "Adaptive design reuse can significantly benefit people in everyday life by promoting efficiency,\n",
            "sustainability, and improved user experiences. Imagine a neighborhood called EcoHomes, where all the\n",
            "houses are built using old materials from buildings that were taken down or left unused. It is all about\n",
            "making new homes without needing to produce or buy more materials, which helps the environment. In\n",
            "EcoHomes, architects and builders take things like bricks, glass, and wood from old sites and use them to\n",
            "build new, modern houses. For example, wooden beams from an old barn become part of the living room\n",
            "in a new house, adding a cool, old-time feel to a modern design. Windows from an old office building let in\n",
            "lots of sunlight, cutting down on the need for electric lights. EcoHomes is a hit because it shows how\n",
            "reusing building materials can save money and help the planet. The people living there have lower energy\n",
            "bills and are proud of their unique, eco-friendly homes. This story shows how using what we already have in\n",
            "new ways can make a big difference for our wallets and the world.\n",
            "2.3 Evolving Architectures into Useable Products\n",
            "Learning Objectives\n",
            "By the end of this section, you will be able to:\n",
            "• Analyze similarities between architectures and apply patterns\n",
            "• Discuss how to accelerate the creation of applications\n",
            "The combination of top-down, adaptive design reuse, and bottom-up, computational thinking, optimizes\n",
            "modern software development. This blend allows software developers to find a middle ground by adapting\n",
            "and assembling existing components, minimizing the need for developing entirely new software. A clear\n",
            "example of this cooperation is evident in modern websites, where the Model-View-Controller architectural\n",
            "pattern is widely employed. The Model-View-Controller (MVC)is a software architectural pattern commonly\n",
            "used in the design of interactive applications, providing a systematic way to organize and structure code. The\n",
            "pattern separates an application into three interconnected components: model, view, and controller. The\n",
            "model represents the application’s data structure and business logic, managing data and rules. The view is\n",
            "responsible for displaying the user interface; it shows data to the user and sends user commands to the\n",
            "controller. The controller serves as an intermediary between the model and the view. It processes user input\n",
            "received from the view, interacts with the model to retrieve or update data, and determines the appropriate\n",
            "view for presenting the response. Many practical web application frameworks, such as Django, have already\n",
            "implemented the MVC pattern. In this setup, the application is divided into three parts: the model handles the\n",
            "data structure, the view displays the data on web pages, and the controller manages the business logic,\n",
            "facilitating interaction between the model and the view. Adding a broker pattern to MVC architectures can\n",
            "improve the system’s scalability and flexibility when applicable and/or necessary. The broker acts as a\n",
            "middleman that manages communication between different parts of the application, helping to handle more\n",
            "data and complex operations efficiently.\n",
            "Leveraging these existing frameworks enables developers to concentrate on crafting the specific logic relevant\n",
            "to the website rather than reinventing the wheel. The beauty of this approach lies in the ability to swiftly piece\n",
            "together solutions by extending and adapting the available frameworks. By doing so, developers streamline\n",
            "the development process, enhance efficiency, and capitalize on the collective wisdom embedded in proven\n",
            "2.3 • Evolving Architectures into Useable Products 73frameworks, thereby fostering innovation in a more focused and resource-efficient manner.\n",
            "Leveraging Architectural Similarities and Applying Patterns\n",
            "The adaptive design reuse approach is a strategy in software development that emphasizes the efficient reuse\n",
            "of existing design solutions to create new systems or applications. The beauty of the adaptive design reuse\n",
            "approach is that the business solution architecture model helps create abstract representations of real\n",
            "systems. Therefore, if there exist tangible realizations of the various components that are part of these\n",
            "abstract representations, it is possible to implement the model and create specialized running business\n",
            "solutions from it.\n",
            "A solutions continuumis a strategy where existing solutions, components, or patterns are leveraged and\n",
            "adapted for use in different contexts. Figure 2.24 illustrates the TOGAF model of reuse that is referred to as the\n",
            "solutions continuum. As mentioned earlier, TOGAF does not provide a prescriptive approach to creating and/or\n",
            "managing a catalog of patterns. However, various pattern repositories are available on the Internet and the\n",
            "adaptive design technique can be used to avoid having to reinvent the wheel when architectural patterns and\n",
            "related component implementations exist and can be customized and assembled with new components. More\n",
            "information on this topic is provided in Chapter 10 Enterprise and Solution Architectures Management.\n",
            "Figure2.24 This TOGAF solutions continuum illustrates how each architecture guides and supports the others. (attribution:\n",
            "Copyright Rice University, OpenStax, under CC BY 4.0 license)\n",
            "As illustrated in Figure 2.25, the TOGAF solutions continuum offers a limited set of dimensions. It serves as a\n",
            "guideline, and The Open Group allows interested parties to enhance the model by incorporating additional\n",
            "dimensions that are relevant to their specific needs.\n",
            "74 2 • Computational Thinking and Design Reusability\n",
            "Access for free at openstax.org\n",
            "----------------------------------------------------------------------------------------------------\n",
            "\n",
            "\n",
            "Snippet 16:\n",
            "n, whereas DLD is based on extending the HLD.\n",
            "DLD should, however, still align with the requirements.\n",
            "• HLD provides elements such as data and information design, whereas DLD provides the information\n",
            "needed to create the actual programming specification and test plan for using the data.\n",
            "• A solution architect is generally involved with the HLD. Programmers and designers are generally involved\n",
            "with DLD.\n",
            "Software Architecture Work Product\n",
            "The software architecture work product acts as a blueprint of the solution being worked on. Imagine you’re\n",
            "building a house. Before construction begins, you would create a blueprint that outlines the overall structure,\n",
            "major components (foundation, walls, roof), and how they fit together. This blueprint is similar to a software\n",
            "architecture. In software development, a software architecture provides a high-level overview of a software\n",
            "system. It describes the system’s major components, their interrelationships, and how they work together. This\n",
            "high-level representation helps developers understand the overall design before delving into details.\n",
            "4 https://www.visual-paradigm.com/features/archimate-tools/\n",
            "9.2 • Software Engineering Process 453A solution is typically represented at various levels of abstraction. Software design involves using software\n",
            "architectures to represent solutions at a high-level of abstraction. A software architecture constitutes a\n",
            "relatively small, intellectually graspable view of how a solution is structured and how its components work\n",
            "together. The goal of software architecture modeling is to allow the software engineer to view and evaluate the\n",
            "system as a whole before moving to component design. This step enables the software engineer to:\n",
            "• ensure that the design model encompasses the various solution requirements\n",
            "• make it possible to survey various design alternatives early on to facilitate the adoption of the best\n",
            "possible model\n",
            "• limit the risk of building software that does not meet the requirements\n",
            "When you look at a blueprint, you can see the major elements of a building and their relationships to each\n",
            "other. When you look at a software system at a high-level of abstraction, such as the extremely high-level\n",
            "shown in Figure 9.7 of a web browser, you can see its major components and the main connections between\n",
            "them. For example, at a high-level, a web browser connects to a web server via HTTP requests, and the web\n",
            "server interacts with a relational database via SQL queries to create an HTML web page that is rendered\n",
            "dynamically and sent back to the web browser for display.\n",
            "Figure 9.7 The software architecture displays a system’s major components (in this case, web browser, web server, and database) and\n",
            "connections (HTTP requests and SQL queries) at a high-level of abstraction. (attribution: Copyright Rice University, OpenStax, under\n",
            "CC BY 4.0 license)\n",
            "Software architecture is an important part of the creation of a software solution, and it should always be\n",
            "designed by an experienced software engineer because changes in the software architecture typically have\n",
            "drastic effects on the solution implementation such as constructing solutions that do not meet the\n",
            "nonfunctional requirements.\n",
            "When designing software architecture, you can leverage various types of software patterns that facilitate the\n",
            "reuse of preexisting solutions. Two examples of such patterns are an architectural style and architectural or\n",
            "design pattern. An architectural style is a transformation that is imposed on the design of an entire system.\n",
            "The intent is to establish a structure for all components of the system. Architectural or design patterns also\n",
            "impose a transformation on the design of an architecture, but they differ from a style because they operate at\n",
            "a lower level of abstraction. Patterns can be used in conjunction with an architectural style that shapes the\n",
            "overall structure of a system.\n",
            "A software architecture is one of the work products that results from the HLD software engineering action.\n",
            "Software architectures are important work products because they provide high-level representations of\n",
            "solutions that facilitate communication among all stakeholders. They also highlight early design decisions that\n",
            "have a profound impact on all software engineering work that follows\n",
            "When it comes to Agile software processes, the goal of creating software architecture work products as part of\n",
            "the HLD software engineering action is to avoid rework. In that case, user stories are leveraged to create and\n",
            "evolve an architectural model (sometimes referred to as a “walking skeleton”) before constructing the\n",
            "software. The use of Agile software processes sometimes makes it difficult to manage architectural design\n",
            "especially when the team is developing large systems from scratch rather than adding small services\n",
            "piecemeal to an existing system. Agile approaches typically focus on small increments for which it may be\n",
            "difficult to produce an all-encompassing architecture that will be able to accommodate subsequent increments\n",
            "that have not been completely defined yet. This may lead to having to refactor the architecture, which could be\n",
            "very costly, as it may require changing a lot of the code that has already been developed. Therefore, it is\n",
            "recommended that teams thoroughly consider architectural design when taking on large projects that do not\n",
            "454 9 • Software Engineering\n",
            "Access for free at openstax.orgbuild on an already defined and solid architecture. This brings up the question as to whether big design up\n",
            "front (BDUF) is the preferred method in this case. It is also the reason Agile teams should include software\n",
            "engineers with a strong background in architecture (ideally, (enterprise architecture), who can foresee the type\n",
            "of designs that are required to avoid costly refactoring efforts in the future.\n",
            "The Scrum and Kanban Agile process models, as you’ll learn later in the chapter, allow software architects to\n",
            "add user stories to the evolving storyboard and to work with the product owner to prioritize their architectural\n",
            "stories in work units called sprints. Well-run Agile projects include the delivery of software architecture\n",
            "documentation during each sprint. After the sprint is complete, the architect reviews the working prototype for\n",
            "quality before the team presents it to the stakeholders in a formal sprint review.\n",
            "As mentioned earlier, the focus of the HLD software engineering action is on providing a general description of\n",
            "the overall system design. It can include information on the overall aspects of a system, including its\n",
            "architecture, data, systems, services, and platforms as well as the relationships among various modules and\n",
            "components. Its focus is achieved by convert\n",
            "----------------------------------------------------------------------------------------------------\n",
            "\n",
            "\n"
          ]
        }
      ],
      "source": [
        "context_snippets = context_result.snippets\n",
        "\n",
        "\n",
        "for num, snippet in enumerate(context_snippets):\n",
        "    print(f\"Snippet {num+1}:\")\n",
        "    print(snippet.content)\n",
        "    print(\"-\"*100)\n",
        "    print(\"\\n\")"
      ]
    },
    {
      "attachments": {},
      "cell_type": "markdown",
      "metadata": {
        "id": "b-3oolT5cCR8"
      },
      "source": [
        "## Building our study guide generator with OpenAI and LangGraph"
      ]
    },
    {
      "attachments": {},
      "cell_type": "markdown",
      "metadata": {
        "id": "DcZ12U06cCH5"
      },
      "source": [
        "Now that we've built our Assistant, we can architect the rest of our application!\n",
        "\n",
        "We'll be using LangGraph to create a study guide generator. This generator will create study guides in response to user queries about our book.\n",
        "\n",
        "To make the application a bit more interesting, we'll add the following functionalities (or nodes)\n",
        "\n",
        "1. Query Generator and Call: A node that can rewrite user messages into queries, and call our Context API\n",
        "2. Study Guide Generator: A node that can create study guides based on retrieved context and queries\n",
        "3. Feedback: A node that reviews the created study guides using a rubric.\n",
        "\n",
        "\n",
        "Second, we'll need \"edges\" or connections between each node that describe the desired architecture.\n",
        "\n",
        "We'll add the following:\n",
        "1. An edge from our query generator to our study guide generator, so that we can inform the latter about the retrieved context\n",
        "2. An edge from our study guide generator to our feedback bot, and back, so we can iterate on edits to the guide\n",
        "3. An edge to our query generator from our feedback bot, so we can do more queries based on what information we are missing\n",
        "4. A completion point after the feedback bot deems our study guide worthy!\n",
        "\n",
        "\n",
        "Putting together these edges and nodes will give us a graph, which determines how our application will behave given input.\n",
        "\n",
        "Now that we have a high level overview of what we want to build, let's get started!"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### Setting up OpenAI"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 116,
      "metadata": {},
      "outputs": [],
      "source": [
        "#setup OpenAI API Key\n",
        "\n",
        "def get_openai_api_key():\n",
        "    \"\"\"\n",
        "    Get OpenAI API key from environment variable or prompt user for input.\n",
        "    Returns the API key as a string.\n",
        "    \"\"\"\n",
        "    api_key = os.environ.get(\"OPENAI_API_KEY\")\n",
        "    \n",
        "    if api_key is None:\n",
        "        try:\n",
        "            api_key = getpass(\"Please enter your OpenAI API key: \")\n",
        "            # Save to environment for future use in session\n",
        "            os.environ[\"OPENAI_API_KEY\"] = api_key\n",
        "        except Exception as e:\n",
        "            print(f\"Error getting OpenAI API key: {e}\")\n",
        "            return None\n",
        "    \n",
        "    return api_key\n",
        "\n",
        "OPENAI_API_KEY = get_openai_api_key()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### Making a Textbook Assistant Search Tool\n",
        "\n",
        "In order for our LLM to call our Context API, we need to set it up as a LangChain tool so it is callable.\n",
        "\n",
        "Here, we define a docstring, add the context API call, and concantenate the output together into a large string for our models to later ingest.\n",
        "\n",
        "This is a really simple way of processing the output, but you can write this tool however you desire for a better result."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 117,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Let's add our assistant as a tool to our graph\n",
        "\n",
        "\n",
        "\n",
        "from langchain_core.tools import tool\n",
        "\n",
        "@tool(\"ask_textbook_subagent_tool\", parse_docstring=True)\n",
        "def ask_textbook_assistant(subquery):\n",
        "    \"\"\"Request information from our Pinecone Assistant.\n",
        "\n",
        "    Pinecone textbook assistant has access to a 1k page computer science textbook\n",
        "    Will return relevant context snippets from the textbook given a query.\n",
        "\n",
        "    Useful for constructing study guides, informative answers, or looking up information from our textbook quickly\n",
        "    \"\"\"\n",
        "\n",
        "    assistant = pc.assistant.Assistant(\n",
        "        assistant_name=\"textbook-assistant\", \n",
        "    )\n",
        "\n",
        "    response = assistant.context(query=subquery)\n",
        "    response_snippets = \"\\n\\n\".join([f\"Snippet {i+1}:\\n{snippet['content']}\\nCited Pages: {', '.join(map(str, snippet['reference']['pages']))}\" for i, snippet in enumerate(response.snippets)])\n",
        "\n",
        "    return response_snippets\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 118,
      "metadata": {},
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Snippet 1:\n",
            "4. Algorithmic thinking: Develop a systematic approach to allocate monthly income.\n",
            "By using computational thinking, you can manage your finances more effectively, ensuring they cover\n",
            "essential costs while maximizing their savings.\n",
            "Abstraction\n",
            "Abstraction makes it possible to pull out the important details and identify principles that apply to other\n",
            "problems or situations. When applying abstraction, it may be useful to write down some notes or draw\n",
            "diagrams to help understand how to resolve the problem. In the jam sandwich example, abstraction means\n",
            "forming an idea of what the sandwich should look like. To apply abstraction here, you would create a model or\n",
            "draw a picture representing the final appearance of the jam sandwich once it is made. This simplifies the\n",
            "details, providing a clearer image of the desired outcome. Simple tools like the Windows Paint program can be\n",
            "used to do this, as shown in Figure 2.5.\n",
            "Figure 2.5 This jam sandwich abstraction example illustrates what the final product should look like. (attribution: Copyright Rice\n",
            "University, OpenStax, under CC BY 4.0 license)\n",
            "In technology, data are represented at different levels of abstraction to simplify user interaction and manage\n",
            "complex operations efficiently. Users interact with a web application through a straightforward interface, like\n",
            "requesting help from a GenAI tool, without seeing the underlying complexity. This GenAI prompt is then\n",
            "processed by the application’s logic, which validates and directs it appropriately, often invisibly to the user.\n",
            "Finally, at the back end, the prompt is processed and a GenAI-generated response is provided. Each layer of\n",
            "abstraction serves a separate role, making the entire process efficient for both the user and the system (Figure\n",
            "2.6).\n",
            "46 2 • Computational Thinking and Design Reusability\n",
            "Access for free at openstax.orgFigure 2.6 When using GenAI, a user interacts with the interface while the application processes the prompt with layers of\n",
            "abstraction on the back end. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)\n",
            "Algorithm\n",
            "An algorithm is a sequence of steps/instructions that must be followed in a specific order to solve a problem.\n",
            "Algorithms make it possible to describe a solution to a problem by writing down the instructions that are\n",
            "required to solve the problem. Computer programs typically execute algorithms to perform certain tasks. In\n",
            "the jam sandwich example, the algorithm technique is about writing instructions that the robot can follow to\n",
            "make the jam sandwich. As you will learn in Chapter 3 Data Structures and Algorithms, algorithms are most\n",
            "commonly written as either pseudocode or a flowchart. An outline of the logic of algorithms using a\n",
            "combination of language and high-level programming concepts is called pseudocode. Each step is shown in a\n",
            "clearly ordered, written structure. A flowchart clearly shows the flow and direction of decisions in a visual way\n",
            "using a diagram. Either way is fine, and it is a matter of personal preference. Basic templates for the flowchart\n",
            "and pseudocode are in Figure 2.7.\n",
            "Figure 2.7 Pseudocode lists each step, while a flowchart visually outlines the process of decision-making. (attribution: Copyright Rice\n",
            "University, OpenStax, under CC BY 4.0 license)\n",
            "Writing algorithms requires practice. Not everyone likes butter in their jam sandwich. The robot needs a\n",
            "method of making sure it adds or does not add butter, depending on preferences. It is therefore necessary to\n",
            "account for the following steps in the pseudocode and flowchart:\n",
            "2.1 • Computational Thinking 471. Ask whether there should be butter on the bread.\n",
            "2. Either spread butter on the bread,\n",
            "3. Or, do not use butter.\n",
            "These steps can be added as actions in the table previously shown and expressed as steps in the pseudocode\n",
            "using programming keywords such as INPUT, OUTPUT, IF, THEN, ELSE, and START. The corresponding\n",
            "instructions can then be converted into a flowchart using the symbols in Figure 2.8.\n",
            "Figure 2.8 The symbols used in a flowchart are associated with their instructions. (attribution: Copyright Rice University, OpenStax,\n",
            "under CC BY 4.0 license)\n",
            "Algorithm Execution Model Patterns\n",
            "Various patterns of execution models may be used to step through the instructions provided in an algorithm.\n",
            "So far, we have only considered the traditional sequential (i.e., step-by-step) execution model for algorithm\n",
            "instructions. However, it is also possible to leverage parallelism/concurrency and recursion as alternative\n",
            "models to drive the execution of algorithms’ instructions.\n",
            "Parallel/concurrent execution models are typically used to optimize algorithm execution efficiency. As an\n",
            "example, if you and a friend are buying tickets for a movie and there are three independent lines, you may opt\n",
            "for a parallel processing model of execution by having you and your friend join two separate lines to buy the\n",
            "tickets. In that case, you are guaranteed to be able to obtain the tickets quicker assuming one of the lines\n",
            "operating in parallel with the other ends up serving customers faster, which is most often the case. Note that\n",
            "executing the same algorithm simultaneously on a computer may not be possible if you only have one central\n",
            "processing unit (CPU) in your machine. In that case, you can simulate parallelism by having the operating\n",
            "system running on the machine execute the two algorithms concurrently as separate tasks while sharing the\n",
            "single processor resources. This approach is less efficient than true parallelism. More detail on the differences\n",
            "between concurrency and parallelism will be provided in Chapter 4 Linguistic Realization of Algorithms: Low\u0002Level Programming Languages.\n",
            "Recursive models of execution provide another elegant and effective alternative to the traditional sequential\n",
            "model of execution. The problem-solving technique where a process calls itself in order to solve smaller\n",
            "instances of the same problem is called recursion. It can be a powerful tool in programming because it allows\n",
            "for elegant solutions to complex problems by breaking them down into smaller, more manageable parts. By\n",
            "leveraging recursion, programmers can write concise and efficient code to solve a wide range of problems.\n",
            "One of the key advantages of recursion is its ability to handle complex tasks with minimal code. Instead of\n",
            "writing lengthy iterative loops to solve repetitive tasks, recursion allows programmers to define a process that\n",
            "calls itself with modified input parameters, effectively reducing the amount of code needed. However, it’s\n",
            "essential to be cautious when using recursion, as improper implementation can lead to stack overflow errors\n",
            "48 2 • Computational Thinking and Design Reusability\n",
            "Access for free at open\n",
            "Cited Pages: 56, 57, 58\n",
            "\n",
            "Snippet 2:\n",
            "4. Algorithmic thinking: Develop a systematic approach to allocate monthly income.\n",
            "By using computational thinking, you can manage your finances more effectively, ensuring they cover\n",
            "essential costs while maximizing their savings.\n",
            "Abstraction\n",
            "Abstraction makes it possible to pull out the important details and identify principles that apply to other\n",
            "problems or situations. When applying abstraction, it may be useful to write down some notes or draw\n",
            "diagrams to help understand how to resolve the problem. In the jam sandwich example, abstraction means\n",
            "forming an idea of what the sandwich should look like. To apply abstraction here, you would create a model or\n",
            "draw a picture representing the final appearance of the jam sandwich once it is made. This simplifies the\n",
            "details, providing a clearer image of the desired outcome. Simple tools like the Windows Paint program can be\n",
            "used to do this, as shown in Figure 2.5.\n",
            "Figure 2.5 This jam sandwich abstraction example illustrates what the final product should look like. (attribution: Copyright Rice\n",
            "University, OpenStax, under CC BY 4.0 license)\n",
            "In technology, data are represented at different levels of abstraction to simplify user interaction and manage\n",
            "complex operations efficiently. Users interact with a web application through a straightforward interface, like\n",
            "requesting help from a GenAI tool, without seeing the underlying complexity. This GenAI prompt is then\n",
            "processed by the application’s logic, which validates and directs it appropriately, often invisibly to the user.\n",
            "Finally, at the back end, the prompt is processed and a GenAI-generated response is provided. Each layer of\n",
            "abstraction serves a separate role, making the entire process efficient for both the user and the system (Figure\n",
            "2.6).\n",
            "46 2 • Computational Thinking and Design Reusability\n",
            "Access for free at openstax.orgFigure 2.6 When using GenAI, a user interacts with the interface while the application processes the prompt with layers of\n",
            "abstraction on the back end. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)\n",
            "Algorithm\n",
            "An algorithm is a sequence of steps/instructions that must be followed in a specific order to solve a problem.\n",
            "Algorithms make it possible to describe a solution to a problem by writing down the instructions that are\n",
            "required to solve the problem. Computer programs typically execute algorithms to perform certain tasks. In\n",
            "the jam sandwich example, the algorithm technique is about writing instructions that the robot can follow to\n",
            "make the jam sandwich. As you will learn in Chapter 3 Data Structures and Algorithms, algorithms are most\n",
            "commonly written as either pseudocode or a flowchart. An outline of the logic of algorithms using a\n",
            "combination of language and high-level programming concepts is called pseudocode. Each step is shown in a\n",
            "clearly ordered, written structure. A flowchart clearly shows the flow and direction of decisions in a visual way\n",
            "using a diagram. Either way is fine, and it is a matter of personal preference. Basic templates for the flowchart\n",
            "and pseudocode are in Figure 2.7.\n",
            "Figure 2.7 Pseudocode lists each step, while a flowchart visually outlines the process of decision-making. (attribution: Copyright Rice\n",
            "University, OpenStax, under CC BY 4.0 license)\n",
            "Writing algorithms requires practice. Not everyone likes butter in their jam sandwich. The robot needs a\n",
            "method of making sure it adds or does not add butter, depending on preferences. It is therefore necessary to\n",
            "account for the following steps in the pseudocode and flowchart:\n",
            "2.1 • Computational Thinking 471. Ask whether there should be butter on the bread.\n",
            "2. Either spread butter on the bread,\n",
            "3. Or, do not use butter.\n",
            "These steps can be added as actions in the table previously shown and expressed as steps in the pseudocode\n",
            "using programming keywords such as INPUT, OUTPUT, IF, THEN, ELSE, and START. The corresponding\n",
            "instructions can then be converted into a flowchart using the symbols in Figure 2.8.\n",
            "Figure 2.8 The symbols used in a flowchart are associated with their instructions. (attribution: Copyright Rice University, OpenStax,\n",
            "under CC BY 4.0 license)\n",
            "Algorithm Execution Model Patterns\n",
            "Various patterns of execution models may be used to step through the instructions provided in an algorithm.\n",
            "So far, we have only considered the traditional sequential (i.e., step-by-step) execution model for algorithm\n",
            "instructions. However, it is also possible to leverage parallelism/concurrency and recursion as alternative\n",
            "models to drive the execution of algorithms’ instructions.\n",
            "Parallel/concurrent execution models are typically used to optimize algorithm execution efficiency. As an\n",
            "example, if you and a friend are buying tickets for a movie and there are three independent lines, you may opt\n",
            "for a parallel processing model of execution by having you and your friend join two separate lines to buy the\n",
            "tickets. In that case, you are guaranteed to be able to obtain the tickets quicker assuming one of the lines\n",
            "operating in parallel with the other ends up serving customers faster, which is most often the case. Note that\n",
            "executing the same algorithm simultaneously on a computer may not be possible if you only have one central\n",
            "processing unit (CPU) in your machine. In that case, you can simulate parallelism by having the operating\n",
            "system running on the machine execute the two algorithms concurrently as separate tasks while sharing the\n",
            "single processor resources. This approach is less efficient than true parallelism. More detail on the differences\n",
            "between concurrency and parallelism will be provided in Chapter 4 Linguistic Realization of Algorithms: Low\u0002Level Programming Languages.\n",
            "Recursive models of execution provide another elegant and effective alternative to the traditional sequential\n",
            "model of execution. The problem-solving technique where a process calls itself in order to solve smaller\n",
            "instances of the same problem is called recursion. It can be a powerful tool in programming because it allows\n",
            "for elegant solutions to complex problems by breaking them down into smaller, more manageable parts. By\n",
            "leveraging recursion, programmers can write concise and efficient code to solve a wide range of problems.\n",
            "One of the key advantages of recursion is its ability to handle complex tasks with minimal code. Instead of\n",
            "writing lengthy iterative loops to solve repetitive tasks, recursion allows programmers to define a process that\n",
            "calls itself with modified input parameters, effectively reducing the amount of code needed. However, it’s\n",
            "essential to be cautious when using recursion, as improper implementation can lead to stack overflow errors\n",
            "48 2 • Computational Thinking and Design Reusability\n",
            "Access for free at open\n",
            "Cited Pages: 56, 57, 58\n",
            "\n",
            "Snippet 3:\n",
            " manageable parts, identifying patterns, extracting essential\n",
            "information, and devising systematic solutions. This process not only applies to technical fields, but also to\n",
            "everyday situations.\n",
            "For example, imagine someone trying to manage their monthly expenses within a tight budget. Here's how\n",
            "you might apply computational thinking to this common problem of managing a monthly budget:\n",
            "1. Decomposition: Break down the financial challenge into different categories such as rent, groceries,\n",
            "utilities, and entertainment.\n",
            "2. Pattern recognition: Analyze past spending to identify patterns.\n",
            "3. Abstraction: Focus on key areas where costs can be reduced.\n",
            "2.1 • Computational Thinking 454. Algorithmic thinking: Develop a systematic approach to allocate monthly income.\n",
            "By using computational thinking, you can manage your finances more effectively, ensuring they cover\n",
            "essential costs while maximizing their savings.\n",
            "Abstraction\n",
            "Abstraction makes it possible to pull out the important details and identify principles that apply to other\n",
            "problems or situations. When applying abstraction, it may be useful to write down some notes or draw\n",
            "diagrams to help understand how to resolve the problem. In the jam sandwich example, abstraction means\n",
            "forming an idea of what the sandwich should look like. To apply abstraction here, you would create a model or\n",
            "draw a picture representing the final appearance of the jam sandwich once it is made. This simplifies the\n",
            "details, providing a clearer image of the desired outcome. Simple tools like the Windows Paint program can be\n",
            "used to do this, as shown in Figure 2.5.\n",
            "Figure2.5 This jam sandwich abstraction example illustrates what the final product should look like. (attribution: Copyright Rice\n",
            "University, OpenStax, under CC BY 4.0 license)\n",
            "In technology, data are represented at different levels of abstraction to simplify user interaction and manage\n",
            "complex operations efficiently. Users interact with a web application through a straightforward interface, like\n",
            "requesting help from a GenAI tool, without seeing the underlying complexity. This GenAI prompt is then\n",
            "processed by the application’s logic, which validates and directs it appropriately, often invisibly to the user.\n",
            "Finally, at the back end, the prompt is processed and a GenAI-generated response is provided. Each layer of\n",
            "abstraction serves a separate role, making the entire process efficient for both the user and the system (Figure\n",
            "2.6).\n",
            "46 2 • Computational Thinking and Design Reusability\n",
            "Access for free at openstax.orgFigure2.6 When using GenAI, a user interacts with the interface while the application processes the prompt with layers of\n",
            "abstraction on the back end. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)\n",
            "Algorithm\n",
            "An algorithm is a sequence of steps/instructions that must be followed in a specific order to solve a problem.\n",
            "Algorithms make it possible to describe a solution to a problem by writing down the instructions that are\n",
            "required to solve the problem. Computer programs typically execute algorithms to perform certain tasks. In\n",
            "the jam sandwich example, the algorithm technique is about writing instructions that the robot can follow to\n",
            "make the jam sandwich. As you will learn in Chapter 3 Data Structures and Algorithms, algorithms are most\n",
            "commonly written as either pseudocode or a flowchart. An outline of the logic of algorithms using a\n",
            "combination of language and high-level programming concepts is called pseudocode. Each step is shown in a\n",
            "clearly ordered, written structure. A flowchartclearly shows the flow and direction of decisions in a visual way\n",
            "using a diagram. Either way is fine, and it is a matter of personal preference. Basic templates for the flowchart\n",
            "and pseudocode are in Figure 2.7.\n",
            "Figure2.7 Pseudocode lists each step, while a flowchart visually outlines the process of decision-making. (attribution: Copyright Rice\n",
            "University, OpenStax, under CC BY 4.0 license)\n",
            "Writing algorithms requires practice. Not everyone likes butter in their jam sandwich. The robot needs a\n",
            "method of making sure it adds or does not add butter, depending on preferences. It is therefore necessary to\n",
            "account for the following steps in the pseudocode and flowchart:\n",
            "2.1 • Computational Thinking 471. Ask whether there should be butter on the bread.\n",
            "2. Either spread butter on the bread,\n",
            "3. Or, do not use butter.\n",
            "These steps can be added as actions in the table previously shown and expressed as steps in the pseudocode\n",
            "using programming keywords such as INPUT, OUTPUT, IF, THEN, ELSE, and START. The corresponding\n",
            "instructions can then be converted into a flowchart using the symbols in Figure 2.8.\n",
            "Figure2.8 The symbols used in a flowchart are associated with their instructions. (attribution: Copyright Rice University, OpenStax,\n",
            "under CC BY 4.0 license)\n",
            "Algorithm Execution Model Patterns\n",
            "Various patterns of execution models may be used to step through the instructions provided in an algorithm.\n",
            "So far, we have only considered the traditional sequential (i.e., step-by-step) execution model for algorithm\n",
            "instructions. However, it is also possible to leverage parallelism/concurrency and recursion as alternative\n",
            "models to drive the execution of algorithms’ instructions.\n",
            "Parallel/concurrent execution models are typically used to optimize algorithm execution efficiency. As an\n",
            "example, if you and a friend are buying tickets for a movie and there are three independent lines, you may opt\n",
            "for a parallel processing model of execution by having you and your friend join two separate lines to buy the\n",
            "tickets. In that case, you are guaranteed to be able to obtain the tickets quicker assuming one of the lines\n",
            "operating in parallel with the other ends up serving customers faster, which is most often the case. Note that\n",
            "executing the same algorithm simultaneously on a computer may not be possible if you only have one central\n",
            "processing unit (CPU) in your machine. In that case, you can simulate parallelism by having the operating\n",
            "system running on the machine execute the two algorithms concurrently as separate tasks while sharing the\n",
            "single processor resources. This approach is less efficient than true parallelism. More detail on the differences\n",
            "between concurrency and parallelism will be provided in Chapter 4 Linguistic Realization of Algorithms: Low-\n",
            "Level Programming Languages.\n",
            "Recursive models of execution provide another elegant and effective alternative to the traditional sequential\n",
            "model of execution. The problem-solving technique where a process calls itself in order to solve smaller\n",
            "instances of the same problem is called recursion. It can be a powerful tool in programming because it allows\n",
            "for elegant solutions to complex problems by breaking them down into smaller, more manageable parts. By\n",
            "leveraging \n",
            "Cited Pages: 55, 56, 57, 58\n",
            "\n",
            "Snippet 4:\n",
            "earning Objectives\n",
            "By the end of this section, you will be able to:\n",
            "• Describe abstraction levels from the highest to the lowest\n",
            "• Explain application programs abstractions in relation to HLLs and instruction set architectures\n",
            "• Discuss processor abstractions and how microarchitecture supports them\n",
            "• Identify the role of the operating system within abstraction\n",
            "• Discuss examples of new disruptive computer systems\n",
            "When you look around, you see that complex systems can be viewed as layers of abstractions. The removal of\n",
            "unimportant elements of a program or computer code that distract from its process is called abstraction. This\n",
            "way of looking at complex systems makes it easier to understand them. For example, cars are very\n",
            "complicated inventions. At the highest level of abstraction, we look at a car as a set of devices used to operate\n",
            "it such as a steering wheel, brake and accelerator pedals, and so on. If we go to a lower level, we see devices\n",
            "that power the car such as its engine, gears, and spark plugs. If we take these parts and look at how they are\n",
            "designed, then we are at an even lower level where we see metals, plastics, and other materials. The same\n",
            "approach can be applied to computers to understand how they work. We can see computers as several layers\n",
            "of abstractions, as shown in Figure 5.5. For the remaining part of this section, we start from the highest level\n",
            "and then work through each abstraction layer to illustrate how it is used as a building block by the layer before\n",
            "it.\n",
            "200 5 • Hardware Realizations of Algorithms: Computer Systems Design\n",
            "Access for free at openstax.orgFigure5.5 A computer system can be viewed at several levels of abstraction, each one layered on top of the other. (attribution:\n",
            "Copyright Rice University, OpenStax, under CC BY 4.0 license)\n",
            "Computers are just a tool used to solve a problem. You may use computers to play games or listen to music,\n",
            "and in these cases, the problems that the computer is trying to solve are associated with programs that you\n",
            "use for entertainment purposes.\n",
            "The top line in Figure 5.5 starts with the problem; we must have a very precise definition of the problem we are\n",
            "trying to solve with a computer. So, the first step in solving a problem with a computer is to know exactly, and\n",
            "with no vagueness, what we are trying to solve. You cannot make a computer solve a problem unless there is a\n",
            "defined and repeatable set of instructions to solve the problem. You may wonder then why it is necessary to\n",
            "use a computer in the first place if you can solve the problem yourself. Well, computers do not get bored, are\n",
            "precise, and can deal with very large problems. This is why, the next step after problem definition is to lay out\n",
            "the steps for solving the problem. This solution layout is called an algorithm. The algorithm is written in free\n",
            "format; that is, it can be steps written as a bulleted list, it can be a flowchart, or it can be a series of\n",
            "mathematical equations. Regardless of the format you choose for writing the algorithm, the algorithm needs\n",
            "to have a key set of characteristics.\n",
            "The first characteristic is that an algorithm must be unambiguous. Each step of the algorithm must be very\n",
            "well defined and precise. The second characteristic is that the algorithm must be deterministic to be\n",
            "reproducible and repeatable so that the same set of inputs produce the same output. The third characteristic\n",
            "is that the algorithm, when implemented on a computer, must consume a reasonable amount of time and\n",
            "storage based on the problem needs. For example, an algorithm can be finite and precise, but if it requires 100\n",
            "years to generate a result, it is clearly useless. For instance, an algorithm that counts the number of even\n",
            "numbers is not finite because we have an infinite number of even numbers.\n",
            "Assuming we have an algorithm, we then need to prepare it for execution on the computer. First, we must\n",
            "prepare the input before it is ready to be consumed by the computer, so we give the algorithm to a\n",
            "programmer whose job it is to read the algorithm, understand it, and then write a program in a known\n",
            "computer language such as C/C++ or Python. The program tells the computer what to do, but in a formal way\n",
            "rather than a freeform way as an algorithm. At that point, we move to another level of abstraction.\n",
            "5.2 • Computer Levels of Abstraction 201Figure5.6 The resulting program is consumable by a computer during and after testing. (credit: “Programmer Flat Set” by\n",
            "Macrovector_official/FreePik, CC BY 2.0)\n",
            "Application Programs Abstractions\n",
            "Next, the programmer writes a program. The main difference between an algorithm and a program is that the\n",
            "former is written by an algorithm designer and the latter is written by a programmer so that the program can\n",
            "be executed by a machine. These programs are called application programs, or simply, programs, and there\n",
            "are billions of them in existence today. Once the programmer finishes writing the program, there are two\n",
            "more steps before it can be executed by a computer.\n",
            "High-Level Programming Language\n",
            "The program generated in the previous step is written in a programming language. There are many\n",
            "programming languages in the world currently. A high-level language (HLL)is the most evolved method by\n",
            "which a human can direct a computer on how to perform tasks and applications. The phrase high-level means\n",
            "that it is closer to a natural language rather than a machine level language such as strings of 1s and 0s. That is,\n",
            "HLL is more user-friendly, and it is made to make the life of the programmer easier regardless of the hardware\n",
            "or the machine. If you look at the code of a program, you find that it is still in English, yet a restricted version\n",
            "of English with very specific keywords and formats to remove the ambiguity that usually exists in natural\n",
            "human language.\n",
            "Even though HLLs rely on restrictive versions of English, they still use English at a high level. The machine does\n",
            "not understand English and needs a low-level language; therefore, we need yet another next step: assembly\n",
            "language.\n",
            "THINK IT THROUGH\n",
            "One Hundred or One?\n",
            "Since HLLs aim to make the life of the programmers easy, why do we have many HLLs? Why not one\n",
            "language that all programmers use?\n",
            "Programming languages are typically designed to help create readable programs. However, some\n",
            "languages are designed with specific applications in mind. That is, some programming languages are easier\n",
            "to use for designing games, while other languages are meant to address mathematical problems or\n",
            "artificial intelligence. However, we can write any program in any language. But our task will be easier if we\n",
            "use the language that is designed with specific applications in mind.\n",
            "Assembly Language\n",
            "When you look at most mainstream programming languages, you find constructs such as funct\n",
            "Cited Pages: 210, 211, 212\n",
            "\n",
            "Snippet 5:\n",
            " section, you will be able to:\n",
            "• Describe abstraction levels from the highest to the lowest\n",
            "• Explain application programs abstractions in relation to HLLs and instruction set architectures\n",
            "• Discuss processor abstractions and how microarchitecture supports them\n",
            "• Identify the role of the operating system within abstraction\n",
            "• Discuss examples of new disruptive computer systems\n",
            "When you look around, you see that complex systems can be viewed as layers of abstractions. The removal of\n",
            "unimportant elements of a program or computer code that distract from its process is called abstraction. This\n",
            "way of looking at complex systems makes it easier to understand them. For example, cars are very\n",
            "complicated inventions. At the highest level of abstraction, we look at a car as a set of devices used to operate\n",
            "it such as a steering wheel, brake and accelerator pedals, and so on. If we go to a lower level, we see devices\n",
            "that power the car such as its engine, gears, and spark plugs. If we take these parts and look at how they are\n",
            "designed, then we are at an even lower level where we see metals, plastics, and other materials. The same\n",
            "approach can be applied to computers to understand how they work. We can see computers as several layers\n",
            "of abstractions, as shown in Figure 5.5. For the remaining part of this section, we start from the highest level\n",
            "and then work through each abstraction layer to illustrate how it is used as a building block by the layer before\n",
            "it.\n",
            "200 5 • Hardware Realizations of Algorithms: Computer Systems Design\n",
            "Access for free at openstax.orgFigure 5.5 A computer system can be viewed at several levels of abstraction, each one layered on top of the other. (attribution:\n",
            "Copyright Rice University, OpenStax, under CC BY 4.0 license)\n",
            "Computers are just a tool used to solve a problem. You may use computers to play games or listen to music,\n",
            "and in these cases, the problems that the computer is trying to solve are associated with programs that you\n",
            "use for entertainment purposes.\n",
            "The top line in Figure 5.5 starts with the problem; we must have a very precise definition of the problem we are\n",
            "trying to solve with a computer. So, the first step in solving a problem with a computer is to know exactly, and\n",
            "with no vagueness, what we are trying to solve. You cannot make a computer solve a problem unless there is a\n",
            "defined and repeatable set of instructions to solve the problem. You may wonder then why it is necessary to\n",
            "use a computer in the first place if you can solve the problem yourself. Well, computers do not get bored, are\n",
            "precise, and can deal with very large problems. This is why, the next step after problem definition is to lay out\n",
            "the steps for solving the problem. This solution layout is called an algorithm. The algorithm is written in free\n",
            "format; that is, it can be steps written as a bulleted list, it can be a flowchart, or it can be a series of\n",
            "mathematical equations. Regardless of the format you choose for writing the algorithm, the algorithm needs\n",
            "to have a key set of characteristics.\n",
            "The first characteristic is that an algorithm must be unambiguous. Each step of the algorithm must be very\n",
            "well defined and precise. The second characteristic is that the algorithm must be deterministic to be\n",
            "reproducible and repeatable so that the same set of inputs produce the same output. The third characteristic\n",
            "is that the algorithm, when implemented on a computer, must consume a reasonable amount of time and\n",
            "storage based on the problem needs. For example, an algorithm can be finite and precise, but if it requires 100\n",
            "years to generate a result, it is clearly useless. For instance, an algorithm that counts the number of even\n",
            "numbers is not finite because we have an infinite number of even numbers.\n",
            "Assuming we have an algorithm, we then need to prepare it for execution on the computer. First, we must\n",
            "prepare the input before it is ready to be consumed by the computer, so we give the algorithm to a\n",
            "programmer whose job it is to read the algorithm, understand it, and then write a program in a known\n",
            "computer language such as C/C++ or Python. The program tells the computer what to do, but in a formal way\n",
            "rather than a freeform way as an algorithm. At that point, we move to another level of abstraction.\n",
            "5.2 • Computer Levels of Abstraction 201Figure 5.6 The resulting program is consumable by a computer during and after testing. (credit: “Programmer Flat Set” by\n",
            "Macrovector_official/FreePik, CC BY 2.0)\n",
            "Application Programs Abstractions\n",
            "Next, the programmer writes a program. The main difference between an algorithm and a program is that the\n",
            "former is written by an algorithm designer and the latter is written by a programmer so that the program can\n",
            "be executed by a machine. These programs are called application programs, or simply, programs, and there\n",
            "are billions of them in existence today. Once the programmer finishes writing the program, there are two\n",
            "more steps before it can be executed by a computer.\n",
            "High-Level Programming Language\n",
            "The program generated in the previous step is written in a programming language. There are many\n",
            "programming languages in the world currently. A high-level language (HLL) is the most evolved method by\n",
            "which a human can direct a computer on how to perform tasks and applications. The phrase high-level means\n",
            "that it is closer to a natural language rather than a machine level language such as strings of 1s and 0s. That is,\n",
            "HLL is more user-friendly, and it is made to make the life of the programmer easier regardless of the hardware\n",
            "or the machine. If you look at the code of a program, you find that it is still in English, yet a restricted version\n",
            "of English with very specific keywords and formats to remove the ambiguity that usually exists in natural\n",
            "human language.\n",
            "Even though HLLs rely on restrictive versions of English, they still use English at a high level. The machine does\n",
            "not understand English and needs a low-level language; therefore, we need yet another next step: assembly\n",
            "language.\n",
            "THINK IT THROUGH\n",
            "One Hundred or One?\n",
            "Since HLLs aim to make the life of the programmers easy, why do we have many HLLs? Why not one\n",
            "language that all programmers use?\n",
            "Programming languages are typically designed to help create readable programs. However, some\n",
            "languages are designed with specific applications in mind. That is, some programming languages are easier\n",
            "to use for designing games, while other languages are meant to address mathematical problems or\n",
            "artificial intelligence. However, we can write any program in any language. But our task will be easier if we\n",
            "use the language that is designed with specific applications in mind.\n",
            "Assembly Language\n",
            "When you look at most mainstream programming lan\n",
            "Cited Pages: 210, 211, 212\n",
            "\n",
            "Snippet 6:\n",
            " section, you will be able to:\n",
            "• Describe abstraction levels from the highest to the lowest\n",
            "• Explain application programs abstractions in relation to HLLs and instruction set architectures\n",
            "• Discuss processor abstractions and how microarchitecture supports them\n",
            "• Identify the role of the operating system within abstraction\n",
            "• Discuss examples of new disruptive computer systems\n",
            "When you look around, you see that complex systems can be viewed as layers of abstractions. The removal of\n",
            "unimportant elements of a program or computer code that distract from its process is called abstraction. This\n",
            "way of looking at complex systems makes it easier to understand them. For example, cars are very\n",
            "complicated inventions. At the highest level of abstraction, we look at a car as a set of devices used to operate\n",
            "it such as a steering wheel, brake and accelerator pedals, and so on. If we go to a lower level, we see devices\n",
            "that power the car such as its engine, gears, and spark plugs. If we take these parts and look at how they are\n",
            "designed, then we are at an even lower level where we see metals, plastics, and other materials. The same\n",
            "approach can be applied to computers to understand how they work. We can see computers as several layers\n",
            "of abstractions, as shown in Figure 5.5. For the remaining part of this section, we start from the highest level\n",
            "and then work through each abstraction layer to illustrate how it is used as a building block by the layer before\n",
            "it.\n",
            "200 5 • Hardware Realizations of Algorithms: Computer Systems Design\n",
            "Access for free at openstax.orgFigure 5.5 A computer system can be viewed at several levels of abstraction, each one layered on top of the other. (attribution:\n",
            "Copyright Rice University, OpenStax, under CC BY 4.0 license)\n",
            "Computers are just a tool used to solve a problem. You may use computers to play games or listen to music,\n",
            "and in these cases, the problems that the computer is trying to solve are associated with programs that you\n",
            "use for entertainment purposes.\n",
            "The top line in Figure 5.5 starts with the problem; we must have a very precise definition of the problem we are\n",
            "trying to solve with a computer. So, the first step in solving a problem with a computer is to know exactly, and\n",
            "with no vagueness, what we are trying to solve. You cannot make a computer solve a problem unless there is a\n",
            "defined and repeatable set of instructions to solve the problem. You may wonder then why it is necessary to\n",
            "use a computer in the first place if you can solve the problem yourself. Well, computers do not get bored, are\n",
            "precise, and can deal with very large problems. This is why, the next step after problem definition is to lay out\n",
            "the steps for solving the problem. This solution layout is called an algorithm. The algorithm is written in free\n",
            "format; that is, it can be steps written as a bulleted list, it can be a flowchart, or it can be a series of\n",
            "mathematical equations. Regardless of the format you choose for writing the algorithm, the algorithm needs\n",
            "to have a key set of characteristics.\n",
            "The first characteristic is that an algorithm must be unambiguous. Each step of the algorithm must be very\n",
            "well defined and precise. The second characteristic is that the algorithm must be deterministic to be\n",
            "reproducible and repeatable so that the same set of inputs produce the same output. The third characteristic\n",
            "is that the algorithm, when implemented on a computer, must consume a reasonable amount of time and\n",
            "storage based on the problem needs. For example, an algorithm can be finite and precise, but if it requires 100\n",
            "years to generate a result, it is clearly useless. For instance, an algorithm that counts the number of even\n",
            "numbers is not finite because we have an infinite number of even numbers.\n",
            "Assuming we have an algorithm, we then need to prepare it for execution on the computer. First, we must\n",
            "prepare the input before it is ready to be consumed by the computer, so we give the algorithm to a\n",
            "programmer whose job it is to read the algorithm, understand it, and then write a program in a known\n",
            "computer language such as C/C++ or Python. The program tells the computer what to do, but in a formal way\n",
            "rather than a freeform way as an algorithm. At that point, we move to another level of abstraction.\n",
            "5.2 • Computer Levels of Abstraction 201Figure 5.6 The resulting program is consumable by a computer during and after testing. (credit: “Programmer Flat Set” by\n",
            "Macrovector_official/FreePik, CC BY 2.0)\n",
            "Application Programs Abstractions\n",
            "Next, the programmer writes a program. The main difference between an algorithm and a program is that the\n",
            "former is written by an algorithm designer and the latter is written by a programmer so that the program can\n",
            "be executed by a machine. These programs are called application programs, or simply, programs, and there\n",
            "are billions of them in existence today. Once the programmer finishes writing the program, there are two\n",
            "more steps before it can be executed by a computer.\n",
            "High-Level Programming Language\n",
            "The program generated in the previous step is written in a programming language. There are many\n",
            "programming languages in the world currently. A high-level language (HLL) is the most evolved method by\n",
            "which a human can direct a computer on how to perform tasks and applications. The phrase high-level means\n",
            "that it is closer to a natural language rather than a machine level language such as strings of 1s and 0s. That is,\n",
            "HLL is more user-friendly, and it is made to make the life of the programmer easier regardless of the hardware\n",
            "or the machine. If you look at the code of a program, you find that it is still in English, yet a restricted version\n",
            "of English with very specific keywords and formats to remove the ambiguity that usually exists in natural\n",
            "human language.\n",
            "Even though HLLs rely on restrictive versions of English, they still use English at a high level. The machine does\n",
            "not understand English and needs a low-level language; therefore, we need yet another next step: assembly\n",
            "language.\n",
            "THINK IT THROUGH\n",
            "One Hundred or One?\n",
            "Since HLLs aim to make the life of the programmers easy, why do we have many HLLs? Why not one\n",
            "language that all programmers use?\n",
            "Programming languages are typically designed to help create readable programs. However, some\n",
            "languages are designed with specific applications in mind. That is, some programming languages are easier\n",
            "to use for designing games, while other languages are meant to address mathematical problems or\n",
            "artificial intelligence. However, we can write any program in any language. But our task will be easier if we\n",
            "use the language that is designed with specific applications in mind.\n",
            "Assembly Language\n",
            "When you look at most mainstream programming lan\n",
            "Cited Pages: 210, 211, 212\n",
            "\n",
            "Snippet 7:\n",
            "Many applications use distance as the metric for edge weight,\n",
            "so the shortest path between two points represents the real-world route with the smallest distance\n",
            "between the two places.\n",
            "What does a distance metric not consider when providing a recommended route? What values are centered\n",
            "and emphasized by even using a shortest paths algorithm for recommending routes?\n",
            "Dijkstra’s Algorithm\n",
            "Dijkstra’s algorithm maintains a priority queue of vertices in the graph ordered by distance from the start\n",
            "and repeatedly selects the next shortest path to an unconnected part of the graph. Dijkstra’s algorithm is\n",
            "almost identical to Prim’s algorithm except processing shortest paths (sequences of edges) rather than\n",
            "individual edges. Dijkstra’s algorithm grows a shortest paths tree one shortest path at a time by selecting the\n",
            "next shortest path to an unexplored vertex. The runtime of Dijkstra’s algorithm is in O(|E| log |V| + |V| log\n",
            "|V|) with respect to |V|, the number of vertices, and |E|, the number of edges (Figure 3.31).\n",
            "Figure 3.31 Dijkstra’s algorithm expands outward from the start vertex by repeatedly selecting the next lowest-cost path to an\n",
            "unreached vertex. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)\n",
            "126 3 • Data Structures and Algorithms\n",
            "Access for free at openstax.org3.6 Computer Science Theory\n",
            "Learning Objectives\n",
            "By the end of this section, you will be able to:\n",
            "• Understand the models and limits of computing\n",
            "• Relate Turing machines to algorithms\n",
            "• Describe complexity classes\n",
            "• Interpret NP-completeness\n",
            "• Differentiate between P and NP\n",
            "Throughout this chapter, we have introduced several techniques and canonical case studies for the design and\n",
            "analysis of algorithms—oftentimes focusing on the ideas and details behind individual algorithms. But the\n",
            "study of algorithms is more than just the study of individual algorithms, algorithm design, or even algorithm\n",
            "analysis.\n",
            "Models of Computation\n",
            "Computers include basic algorithms for solving problems like adding, subtracting, or comparing two numbers.\n",
            "Computers, owing to their roots in calculators, are optimized to solve these problems; these basic algorithms\n",
            "are constant-time operations. What programming offers is the ability to define our own algorithms that can be\n",
            "used to solve more complex problems, such as searching, sorting, and hashing. Unfortunately, these\n",
            "programmed algorithms are not as fast as basic operations. We have even seen certain problems deal with a\n",
            "combinatorial explosion in the number of potential solutions. For many of these problems, the best-known\n",
            "algorithms do not do much better than brute-force, which takes exponential time.\n",
            "In the bigger picture, computer science engages the central question of how humans can encode intelligence.\n",
            "Our discussion of algorithm design grounded the activity in problem modeling, the process of encoding a\n",
            "complex real-world phenomenon or problem in a more abstract or simple form. How is problem modeling\n",
            "constrained by the model of computation, or the rules of the underlying computer that executes an algorithm?\n",
            "Why are certain problems challenging for computers to execute?\n",
            "Combinatorial explosion poses a problem for computer algorithms because our model of computation\n",
            "assumes computers only have a single thread of execution and only execute one basic operation on each step.\n",
            "If we overturn some part of this assumption, either by creating computers with multiple processors or by\n",
            "creating more sophisticated operations, then it might be possible to deal with combinatorial explosion. Almost\n",
            "all of today’s computer hardware, ranging from massive supercomputers to handheld smartphones, rely at\n",
            "least to some degree on expanding the model of computation to compute solutions to problems more\n",
            "efficiently. Even so, much of today’s computer hardware still relies on the same fundamental programming\n",
            "assumptions: that there are variables to represent data and arithmetic or logical operations.\n",
            "Turing Machines\n",
            "In the 1800s, Charles Babbage imagined a mechanical machine—the Analytical Engine—that could\n",
            "automatically calculate mathematical formulas. Ada Lovelace then extrapolated that the Analytical Engine\n",
            "could solve more general algorithms by using loops to repeat processes and variables to represent data.\n",
            "Lovelace’s vision of algorithms represented a synthesis between human intuition and mathematical reasoning.\n",
            "In the mid-1900s, Lovelace’s ideas inspired Alan Turing to imagine a more general notion of algorithms and\n",
            "machines that could run those algorithms. A Turing machine is an abstract model of computation for\n",
            "executing any computer algorithm. A Turing machine describes computers in terms of three key ideas:\n",
            "1. a memory bank for storing data.\n",
            "2. an instruction table, where each instruction can either:\n",
            "a. store a value to the memory bank.\n",
            "3.6 • Computer Science Theory 127b. retrieve a value from the memory bank.\n",
            "c. perform a basic operation on a value.\n",
            "d. set which instruction will be executed next by modifying the program counter.\n",
            "3. a program counter that keeps track of the current instruction in the instruction table.\n",
            "A Turing machine executes a computer algorithm by following each instruction specified by the program\n",
            "counter. An algorithm can use these basic operations to compute the sum of 1 and 1.\n",
            "1. Store the value 1 to address A in the memory bank.\n",
            "2. Store the value 1 to address B in the memory bank.\n",
            "3. Add the values at addresses A and B and then store the result at address A.\n",
            "What makes computers useful is not just the fact that they can calculate numbers, but that they can encode\n",
            "logic in the instructions. Instead of just computing the sum of 1 and 1, this program continues adding 1 to a\n",
            "growing sum stored at address A.\n",
            "1. Store the value 1 to address A in the memory bank.\n",
            "2. Store the value 1 to address B in the memory bank.\n",
            "3. Add the values at addresses A and B and then store the result at address A.\n",
            "4. Set the program counter to execute step 3 next.\n",
            "The Turing machine abstract model of computation assumes a single thread of execution following each\n",
            "instruction in an algorithm. Although today’s computers are much more efficient than the first computers that\n",
            "realized the Turing machine, most computers still rely on the same fundamental assumptions about how to\n",
            "execute algorithms. The O(N)-time sequential search algorithm, though it might execute 1,000 times faster on\n",
            "today’s computers, still grows linearly with respect to the size of the input. An O(2N)-time brute-force\n",
            "algorithm, though it might execute 1,000 times faster on today’s computers, still grows exponentially with\n",
            "respect to the size of the input. Even as computers become faster over \n",
            "Cited Pages: 136, 137, 138\n",
            "\n",
            "Snippet 8:\n",
            "Many applications use distance as the metric for edge weight,\n",
            "so the shortest path between two points represents the real-world route with the smallest distance\n",
            "between the two places.\n",
            "What does a distance metric not consider when providing a recommended route? What values are centered\n",
            "and emphasized by even using a shortest paths algorithm for recommending routes?\n",
            "Dijkstra’s Algorithm\n",
            "Dijkstra’s algorithm maintains a priority queue of vertices in the graph ordered by distance from the start\n",
            "and repeatedly selects the next shortest path to an unconnected part of the graph. Dijkstra’s algorithm is\n",
            "almost identical to Prim’s algorithm except processing shortest paths (sequences of edges) rather than\n",
            "individual edges. Dijkstra’s algorithm grows a shortest paths tree one shortest path at a time by selecting the\n",
            "next shortest path to an unexplored vertex. The runtime of Dijkstra’s algorithm is in O(|E| log |V| + |V| log\n",
            "|V|) with respect to |V|, the number of vertices, and |E|, the number of edges (Figure 3.31).\n",
            "Figure 3.31 Dijkstra’s algorithm expands outward from the start vertex by repeatedly selecting the next lowest-cost path to an\n",
            "unreached vertex. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)\n",
            "126 3 • Data Structures and Algorithms\n",
            "Access for free at openstax.org3.6 Computer Science Theory\n",
            "Learning Objectives\n",
            "By the end of this section, you will be able to:\n",
            "• Understand the models and limits of computing\n",
            "• Relate Turing machines to algorithms\n",
            "• Describe complexity classes\n",
            "• Interpret NP-completeness\n",
            "• Differentiate between P and NP\n",
            "Throughout this chapter, we have introduced several techniques and canonical case studies for the design and\n",
            "analysis of algorithms—oftentimes focusing on the ideas and details behind individual algorithms. But the\n",
            "study of algorithms is more than just the study of individual algorithms, algorithm design, or even algorithm\n",
            "analysis.\n",
            "Models of Computation\n",
            "Computers include basic algorithms for solving problems like adding, subtracting, or comparing two numbers.\n",
            "Computers, owing to their roots in calculators, are optimized to solve these problems; these basic algorithms\n",
            "are constant-time operations. What programming offers is the ability to define our own algorithms that can be\n",
            "used to solve more complex problems, such as searching, sorting, and hashing. Unfortunately, these\n",
            "programmed algorithms are not as fast as basic operations. We have even seen certain problems deal with a\n",
            "combinatorial explosion in the number of potential solutions. For many of these problems, the best-known\n",
            "algorithms do not do much better than brute-force, which takes exponential time.\n",
            "In the bigger picture, computer science engages the central question of how humans can encode intelligence.\n",
            "Our discussion of algorithm design grounded the activity in problem modeling, the process of encoding a\n",
            "complex real-world phenomenon or problem in a more abstract or simple form. How is problem modeling\n",
            "constrained by the model of computation, or the rules of the underlying computer that executes an algorithm?\n",
            "Why are certain problems challenging for computers to execute?\n",
            "Combinatorial explosion poses a problem for computer algorithms because our model of computation\n",
            "assumes computers only have a single thread of execution and only execute one basic operation on each step.\n",
            "If we overturn some part of this assumption, either by creating computers with multiple processors or by\n",
            "creating more sophisticated operations, then it might be possible to deal with combinatorial explosion. Almost\n",
            "all of today’s computer hardware, ranging from massive supercomputers to handheld smartphones, rely at\n",
            "least to some degree on expanding the model of computation to compute solutions to problems more\n",
            "efficiently. Even so, much of today’s computer hardware still relies on the same fundamental programming\n",
            "assumptions: that there are variables to represent data and arithmetic or logical operations.\n",
            "Turing Machines\n",
            "In the 1800s, Charles Babbage imagined a mechanical machine—the Analytical Engine—that could\n",
            "automatically calculate mathematical formulas. Ada Lovelace then extrapolated that the Analytical Engine\n",
            "could solve more general algorithms by using loops to repeat processes and variables to represent data.\n",
            "Lovelace’s vision of algorithms represented a synthesis between human intuition and mathematical reasoning.\n",
            "In the mid-1900s, Lovelace’s ideas inspired Alan Turing to imagine a more general notion of algorithms and\n",
            "machines that could run those algorithms. A Turing machine is an abstract model of computation for\n",
            "executing any computer algorithm. A Turing machine describes computers in terms of three key ideas:\n",
            "1. a memory bank for storing data.\n",
            "2. an instruction table, where each instruction can either:\n",
            "a. store a value to the memory bank.\n",
            "3.6 • Computer Science Theory 127b. retrieve a value from the memory bank.\n",
            "c. perform a basic operation on a value.\n",
            "d. set which instruction will be executed next by modifying the program counter.\n",
            "3. a program counter that keeps track of the current instruction in the instruction table.\n",
            "A Turing machine executes a computer algorithm by following each instruction specified by the program\n",
            "counter. An algorithm can use these basic operations to compute the sum of 1 and 1.\n",
            "1. Store the value 1 to address A in the memory bank.\n",
            "2. Store the value 1 to address B in the memory bank.\n",
            "3. Add the values at addresses A and B and then store the result at address A.\n",
            "What makes computers useful is not just the fact that they can calculate numbers, but that they can encode\n",
            "logic in the instructions. Instead of just computing the sum of 1 and 1, this program continues adding 1 to a\n",
            "growing sum stored at address A.\n",
            "1. Store the value 1 to address A in the memory bank.\n",
            "2. Store the value 1 to address B in the memory bank.\n",
            "3. Add the values at addresses A and B and then store the result at address A.\n",
            "4. Set the program counter to execute step 3 next.\n",
            "The Turing machine abstract model of computation assumes a single thread of execution following each\n",
            "instruction in an algorithm. Although today’s computers are much more efficient than the first computers that\n",
            "realized the Turing machine, most computers still rely on the same fundamental assumptions about how to\n",
            "execute algorithms. The O(N)-time sequential search algorithm, though it might execute 1,000 times faster on\n",
            "today’s computers, still grows linearly with respect to the size of the input. An O(2N)-time brute-force\n",
            "algorithm, though it might execute 1,000 times faster on today’s computers, still grows exponentially with\n",
            "respect to the size of the input. Even as computers become faster over \n",
            "Cited Pages: 136, 137, 138\n",
            "\n",
            "Snippet 9:\n",
            " includes identity characteristic data such as age, race, or gender,\n",
            "epidemiologists can study which groups of people are most affected by the disease. This can then inform\n",
            "the distribution of vaccines to assist the most impacted groups first.\n",
            "3.1 • Introduction to Data Structures and Algorithms 99Complex Data\n",
            "Now that we have seen several data structure implementations for abstract data, let us consider how these\n",
            "data structures are used in practice. Recall that we compared calculators whose algorithms operated on\n",
            "numbers with the idea of a computer whose algorithms operated on complex data. Data structures can be\n",
            "used to represent complex data by modeling hierarchy and relationships.\n",
            "We might represent an online retail store as a map associating each item with details such as an image, a brief\n",
            "description, price, and the number of items in stock. This map makes some online storefront features easier to\n",
            "implement than others. Given an item, this map makes it easy to retrieve the details associated with that item.\n",
            "On the other hand, it is not so easy to sort items by price, sort items by popularity, or search for an item by\n",
            "keywords in its description. All these features could be implemented with additional data structures. We can\n",
            "combine multiple data structures together to implement these features. In computer science, we use database\n",
            "systems (see Chapter 8 Data Management) that work behind the scenes in many applications to manage these\n",
            "data structures and facilitate long-term storage and access to large amounts of data.\n",
            "Just as calculators have algorithms for calculating numbers, computers have algorithms for computing\n",
            "complex data. Data structures represent these complex data, and algorithms act on these data structures.\n",
            "3.2 Algorithm Design and Discovery\n",
            "Learning Objectives\n",
            "By the end of this section, you will be able to:\n",
            "• Understand the approach to solving algorithmic problems\n",
            "• Explain how algorithm design patterns are used to solve new problems\n",
            "• Describe how algorithms are analyzed\n",
            "Our introduction to data structures focused primarily on representing complex data. But computer scientists\n",
            "are also interested in designing algorithms for solving a wider variety of problems beyond storing and\n",
            "retrieving data. For example, they may want to plan a route between a start location and an end location on a\n",
            "map. Although every real-world problem is unique, computer scientists can use a general set of principles to\n",
            "design solutions without needing to develop new algorithms from scratch. Just like how many data structures\n",
            "can represent the same abstract data type, many different solutions exist to solve the same problem.\n",
            "Algorithmic Problem Solving\n",
            "An algorithm is a sequence of precise instructions that takes any input and computes the corresponding\n",
            "output, while algorithmic problem-solvingrefers to a particular set of approaches and methods for\n",
            "designing algorithms that draws on computing’s historical connections to the study of mathematical problem\n",
            "solving. Early computer scientists were influenced by mathematical formalism and mathematical problem\n",
            "solving. George Pólya’s 1945 book, How to Solve It, outlines a process for solving problems that begins with a\n",
            "formal understanding of the problem and ends with a solution to the problem. As an algorithm's input size is\n",
            "always finite, finding a solution to an algorithmic problem can always be accomplished by exhaustive search.\n",
            "Therefore, the goal of algorithmic problem-solving, as opposed to mathematical problem solving, is to find an\n",
            "“efficient” solution, either in terms of execution time (e.g., number of computer instructions) or space used\n",
            "(e.g., computer memory size). Consequently, the study of algorithmic problem-solving emphasizes the formal\n",
            "problemor task, with specific input data and output data corresponding to each input. There are many other\n",
            "ways to solve problems with computers, but this mathematical approach remains the dominant approach in\n",
            "the field. Here are a few well-known problems in computer science that we will explore later in this chapter.\n",
            "A data structure problemis a computational problem involving the storage and retrieval of elements for\n",
            "implementing abstract data types such as lists, sets, maps, and priority queues. These include:\n",
            "• searching, or the problem of retrieving a target element from a collection of elements\n",
            "100 3 • Data Structures and Algorithms\n",
            "Access for free at openstax.org• sorting, or the problem of rearranging elements into a logical order\n",
            "• hashing, or the problem of assigning a meaningful integer index for each object\n",
            "A graph problemis a computational problem involving graphs that represent relationships between data.\n",
            "These include:\n",
            "• traversal, or the problem of exploring all the vertices in a graph\n",
            "• minimum spanning treeis the problem of finding a lowest-cost way to connect all the vertices to each\n",
            "other\n",
            "• shortest pathis the problem of finding the lowest-cost way to get from one vertex to another\n",
            "A string problemis a computational problem involving text or information represented as a sequence of\n",
            "characters. Examples include:\n",
            "• matching, or the problem of searching for a text pattern within a document\n",
            "• compression, or the problem of representing information using less data storage\n",
            "• cryptography, or the problem of masking or obfuscating text to make it unintelligible\n",
            "Modeling\n",
            "Computer scientists focus on defining a problem model, often simply called a model, which is a simplified,\n",
            "abstract representation of more complex real-world problems. They apply the algorithmic problem-solving\n",
            "process mentioned previously to design algorithms when defining models. Algorithms model phenomena in\n",
            "the same way that data structures implement abstract data types such as lists, sets, maps, priority queues, and\n",
            "graphs. But unlike abstract data types, models are not necessarily purely abstract or mathematical concepts.\n",
            "Models are often linked to humans and social phenomena. A medical system might want to decide which\n",
            "drugs to administer to which patients, so the algorithm designer might decide to model patients as a complex\n",
            "data type consisting of age, sex, weight, or other physical characteristics. Because models represent\n",
            "abstractions, or simplifications of real phenomena, a model must emphasize some details over others. In the\n",
            "case of the medical system, the algorithm designer emphasized physical characteristics of people that were\n",
            "deemed important and chose to ignore other characteristics, such as political views, which were deemed less\n",
            "important for the model.\n",
            "If an algorithm is a solution to a problem, then the model is the frame through which the algorithm designer\n",
            "defines the rules and potential outcomes. Without models, algorithm designers would struggle with the\n",
            "infinit\n",
            "Cited Pages: 109, 110, 111\n",
            "\n",
            "Snippet 10:\n",
            "they\n",
            "represent the problem.\n",
            "GLOBAL ISSUES IN TECHNOLOGY\n",
            "Contact Tracing\n",
            "Epidemiology is the study of how infectious diseases spread across the world. Within epidemiology, contact\n",
            "tracing attempts to identify confirmed cases of disease and limit its spread by tracing contacted people and\n",
            "isolating them from further spreading the disease.\n",
            "Graph data structures can help epidemiologists manage the data and people involved in contact tracing.\n",
            "Imagine a graph where each vertex in a tracing graph represents a person, and each edge between two\n",
            "people represents a possible contact. When a person receives a positive test result for contracting the\n",
            "disease, healthcare professionals can identify all the people that they’ve been in contact with by tracing\n",
            "through the graph.\n",
            "In addition to improving public health through contact tracing, our imaginary graph can also represent a\n",
            "history of the spread of the disease for epidemiologists to understand how the disease moves through\n",
            "communities. For example, if each vertex includes identity characteristic data such as age, race, or gender,\n",
            "epidemiologists can study which groups of people are most affected by the disease. This can then inform\n",
            "the distribution of vaccines to assist the most impacted groups first.\n",
            "3.1 • Introduction to Data Structures and Algorithms 99Complex Data\n",
            "Now that we have seen several data structure implementations for abstract data, let us consider how these\n",
            "data structures are used in practice. Recall that we compared calculators whose algorithms operated on\n",
            "numbers with the idea of a computer whose algorithms operated on complex data. Data structures can be\n",
            "used to represent complex data by modeling hierarchy and relationships.\n",
            "We might represent an online retail store as a map associating each item with details such as an image, a brief\n",
            "description, price, and the number of items in stock. This map makes some online storefront features easier to\n",
            "implement than others. Given an item, this map makes it easy to retrieve the details associated with that item.\n",
            "On the other hand, it is not so easy to sort items by price, sort items by popularity, or search for an item by\n",
            "keywords in its description. All these features could be implemented with additional data structures. We can\n",
            "combine multiple data structures together to implement these features. In computer science, we use database\n",
            "systems (see Chapter 8 Data Management) that work behind the scenes in many applications to manage these\n",
            "data structures and facilitate long-term storage and access to large amounts of data.\n",
            "Just as calculators have algorithms for calculating numbers, computers have algorithms for computing\n",
            "complex data. Data structures represent these complex data, and algorithms act on these data structures.\n",
            "3.2 Algorithm Design and Discovery\n",
            "Learning Objectives\n",
            "By the end of this section, you will be able to:\n",
            "• Understand the approach to solving algorithmic problems\n",
            "• Explain how algorithm design patterns are used to solve new problems\n",
            "• Describe how algorithms are analyzed\n",
            "Our introduction to data structures focused primarily on representing complex data. But computer scientists\n",
            "are also interested in designing algorithms for solving a wider variety of problems beyond storing and\n",
            "retrieving data. For example, they may want to plan a route between a start location and an end location on a\n",
            "map. Although every real-world problem is unique, computer scientists can use a general set of principles to\n",
            "design solutions without needing to develop new algorithms from scratch. Just like how many data structures\n",
            "can represent the same abstract data type, many different solutions exist to solve the same problem.\n",
            "Algorithmic Problem Solving\n",
            "An algorithm is a sequence of precise instructions that takes any input and computes the corresponding\n",
            "output, while algorithmic problem-solving refers to a particular set of approaches and methods for\n",
            "designing algorithms that draws on computing’s historical connections to the study of mathematical problem\n",
            "solving. Early computer scientists were influenced by mathematical formalism and mathematical problem\n",
            "solving. George Pólya’s 1945 book, How to Solve It, outlines a process for solving problems that begins with a\n",
            "formal understanding of the problem and ends with a solution to the problem. As an algorithm's input size is\n",
            "always finite, finding a solution to an algorithmic problem can always be accomplished by exhaustive search.\n",
            "Therefore, the goal of algorithmic problem-solving, as opposed to mathematical problem solving, is to find an\n",
            "“efficient” solution, either in terms of execution time (e.g., number of computer instructions) or space used\n",
            "(e.g., computer memory size). Consequently, the study of algorithmic problem-solving emphasizes the formal\n",
            "problem or task, with specific input data and output data corresponding to each input. There are many other\n",
            "ways to solve problems with computers, but this mathematical approach remains the dominant approach in\n",
            "the field. Here are a few well-known problems in computer science that we will explore later in this chapter.\n",
            "A data structure problem is a computational problem involving the storage and retrieval of elements for\n",
            "implementing abstract data types such as lists, sets, maps, and priority queues. These include:\n",
            "• searching, or the problem of retrieving a target element from a collection of elements\n",
            "100 3 • Data Structures and Algorithms\n",
            "Access for free at openstax.org• sorting, or the problem of rearranging elements into a logical order\n",
            "• hashing, or the problem of assigning a meaningful integer index for each object\n",
            "A graph problem is a computational problem involving graphs that represent relationships between data.\n",
            "These include:\n",
            "• traversal, or the problem of exploring all the vertices in a graph\n",
            "• minimum spanning tree is the problem of finding a lowest-cost way to connect all the vertices to each\n",
            "other\n",
            "• shortest path is the problem of finding the lowest-cost way to get from one vertex to another\n",
            "A string problem is a computational problem involving text or information represented as a sequence of\n",
            "characters. Examples include:\n",
            "• matching, or the problem of searching for a text pattern within a document\n",
            "• compression, or the problem of representing information using less data storage\n",
            "• cryptography, or the problem of masking or obfuscating text to make it unintelligible\n",
            "Modeling\n",
            "Computer scientists focus on defining a problem model, often simply called a model, which is a simplified,\n",
            "abstract representation of more complex real-world problems. They apply the algorithmic problem-solving\n",
            "process mentioned previously to design algorithms when defining models. Algorithms model phenom\n",
            "Cited Pages: 109, 110, 111\n",
            "\n",
            "Snippet 11:\n",
            "they\n",
            "represent the problem.\n",
            "GLOBAL ISSUES IN TECHNOLOGY\n",
            "Contact Tracing\n",
            "Epidemiology is the study of how infectious diseases spread across the world. Within epidemiology, contact\n",
            "tracing attempts to identify confirmed cases of disease and limit its spread by tracing contacted people and\n",
            "isolating them from further spreading the disease.\n",
            "Graph data structures can help epidemiologists manage the data and people involved in contact tracing.\n",
            "Imagine a graph where each vertex in a tracing graph represents a person, and each edge between two\n",
            "people represents a possible contact. When a person receives a positive test result for contracting the\n",
            "disease, healthcare professionals can identify all the people that they’ve been in contact with by tracing\n",
            "through the graph.\n",
            "In addition to improving public health through contact tracing, our imaginary graph can also represent a\n",
            "history of the spread of the disease for epidemiologists to understand how the disease moves through\n",
            "communities. For example, if each vertex includes identity characteristic data such as age, race, or gender,\n",
            "epidemiologists can study which groups of people are most affected by the disease. This can then inform\n",
            "the distribution of vaccines to assist the most impacted groups first.\n",
            "3.1 • Introduction to Data Structures and Algorithms 99Complex Data\n",
            "Now that we have seen several data structure implementations for abstract data, let us consider how these\n",
            "data structures are used in practice. Recall that we compared calculators whose algorithms operated on\n",
            "numbers with the idea of a computer whose algorithms operated on complex data. Data structures can be\n",
            "used to represent complex data by modeling hierarchy and relationships.\n",
            "We might represent an online retail store as a map associating each item with details such as an image, a brief\n",
            "description, price, and the number of items in stock. This map makes some online storefront features easier to\n",
            "implement than others. Given an item, this map makes it easy to retrieve the details associated with that item.\n",
            "On the other hand, it is not so easy to sort items by price, sort items by popularity, or search for an item by\n",
            "keywords in its description. All these features could be implemented with additional data structures. We can\n",
            "combine multiple data structures together to implement these features. In computer science, we use database\n",
            "systems (see Chapter 8 Data Management) that work behind the scenes in many applications to manage these\n",
            "data structures and facilitate long-term storage and access to large amounts of data.\n",
            "Just as calculators have algorithms for calculating numbers, computers have algorithms for computing\n",
            "complex data. Data structures represent these complex data, and algorithms act on these data structures.\n",
            "3.2 Algorithm Design and Discovery\n",
            "Learning Objectives\n",
            "By the end of this section, you will be able to:\n",
            "• Understand the approach to solving algorithmic problems\n",
            "• Explain how algorithm design patterns are used to solve new problems\n",
            "• Describe how algorithms are analyzed\n",
            "Our introduction to data structures focused primarily on representing complex data. But computer scientists\n",
            "are also interested in designing algorithms for solving a wider variety of problems beyond storing and\n",
            "retrieving data. For example, they may want to plan a route between a start location and an end location on a\n",
            "map. Although every real-world problem is unique, computer scientists can use a general set of principles to\n",
            "design solutions without needing to develop new algorithms from scratch. Just like how many data structures\n",
            "can represent the same abstract data type, many different solutions exist to solve the same problem.\n",
            "Algorithmic Problem Solving\n",
            "An algorithm is a sequence of precise instructions that takes any input and computes the corresponding\n",
            "output, while algorithmic problem-solving refers to a particular set of approaches and methods for\n",
            "designing algorithms that draws on computing’s historical connections to the study of mathematical problem\n",
            "solving. Early computer scientists were influenced by mathematical formalism and mathematical problem\n",
            "solving. George Pólya’s 1945 book, How to Solve It, outlines a process for solving problems that begins with a\n",
            "formal understanding of the problem and ends with a solution to the problem. As an algorithm's input size is\n",
            "always finite, finding a solution to an algorithmic problem can always be accomplished by exhaustive search.\n",
            "Therefore, the goal of algorithmic problem-solving, as opposed to mathematical problem solving, is to find an\n",
            "“efficient” solution, either in terms of execution time (e.g., number of computer instructions) or space used\n",
            "(e.g., computer memory size). Consequently, the study of algorithmic problem-solving emphasizes the formal\n",
            "problem or task, with specific input data and output data corresponding to each input. There are many other\n",
            "ways to solve problems with computers, but this mathematical approach remains the dominant approach in\n",
            "the field. Here are a few well-known problems in computer science that we will explore later in this chapter.\n",
            "A data structure problem is a computational problem involving the storage and retrieval of elements for\n",
            "implementing abstract data types such as lists, sets, maps, and priority queues. These include:\n",
            "• searching, or the problem of retrieving a target element from a collection of elements\n",
            "100 3 • Data Structures and Algorithms\n",
            "Access for free at openstax.org• sorting, or the problem of rearranging elements into a logical order\n",
            "• hashing, or the problem of assigning a meaningful integer index for each object\n",
            "A graph problem is a computational problem involving graphs that represent relationships between data.\n",
            "These include:\n",
            "• traversal, or the problem of exploring all the vertices in a graph\n",
            "• minimum spanning tree is the problem of finding a lowest-cost way to connect all the vertices to each\n",
            "other\n",
            "• shortest path is the problem of finding the lowest-cost way to get from one vertex to another\n",
            "A string problem is a computational problem involving text or information represented as a sequence of\n",
            "characters. Examples include:\n",
            "• matching, or the problem of searching for a text pattern within a document\n",
            "• compression, or the problem of representing information using less data storage\n",
            "• cryptography, or the problem of masking or obfuscating text to make it unintelligible\n",
            "Modeling\n",
            "Computer scientists focus on defining a problem model, often simply called a model, which is a simplified,\n",
            "abstract representation of more complex real-world problems. They apply the algorithmic problem-solving\n",
            "process mentioned previously to design algorithms when defining models. Algorithms model phenom\n",
            "Cited Pages: 109, 110, 111\n",
            "\n",
            "Snippet 12:\n",
            "Relate data structures and abstract data types\n",
            "• Select the data structure that is appropriate to solve a given problem practically\n",
            "Data Structures and Algorithms\n",
            "3Computer science is the study of computers and computational systems that involve data representation and\n",
            "process automation. Owing to their historical roots as calculators, computers can easily represent numerical\n",
            "data. Calculators rely on algorithms to add, subtract, multiply, and divide numbers. But what about more\n",
            "complex data? How do computers represent complex objects like graphs, images, videos, or sentences? What\n",
            "complications arise when we represent or process data in certain ways? These are some of the foundational\n",
            "questions that computer scientists and programmers focus on when designing software and applications that\n",
            "we use to solve problems.\n",
            "A data type determines how computers process data by defining the possible values for data and the possible\n",
            "functionality or operations on that data. For example, the integer data type is defined as values from a certain\n",
            "range of positive or negative whole numbers with functionality including addition, subtraction, multiplication,\n",
            "and division. The string data type is defined as a sequence of characters where each character can be a letter,\n",
            "digit, punctuation, or space, with functionalities that include adding or deleting a character from a string,\n",
            "concatenating strings, and comparing two strings based, for example, on their alphabetical order.\n",
            "Data types like strings are an example of abstraction, the process of simplifying a concept in order to\n",
            "represent it in a computer. The string data type takes a complex concept like a sentence and represents it in\n",
            "terms of more basic data that a computer can work with. When a computer compares two strings, it is really\n",
            "comparing the individual numerical character codes (see Chapter 5 Hardware Realizations of Algorithms:\n",
            "Computer Systems Design) corresponding to each pair of characters within the two strings.\n",
            "In this section, we will learn how to solve problems by choosing abstractions for complex data. We will see that\n",
            "just as our data grows more complex, so do our algorithms.\n",
            "Introduction to Algorithms\n",
            "An algorithm is a sequence of precise instructions that operate on data. We can think of recipes, plans, or\n",
            "instructions from our daily lives as examples of algorithms. Computers can only execute a finite pre-defined\n",
            "set of instructions exactly as instructed, which is why programming can feel like such a different way of\n",
            "communicating as compared to our natural human languages. A program is an implementation (realization)\n",
            "of an algorithm written in a formal programming language.\n",
            "Although each programming language is different from all the others, there are still common ideas across all\n",
            "of them. Knowing just a few of these common ideas enables computer scientists to address a wide variety of\n",
            "problems without having to start from scratch every single time. For example, the abstraction of string data\n",
            "enables programmers to write programs that operate on human-readable letters, digits, punctuation, or\n",
            "spaces without having to determine how to delve into each of these concepts. Programming languages allow\n",
            "us to define abstractions for representing ideas in a computer (see Chapter 4 Linguistic Realization of\n",
            "Algorithms: Low-Level Programming Languages for more).\n",
            "The study of data structures and algorithms focuses on identifying what is known as a canonical algorithm: a\n",
            "well-known algorithm that showcases design principles helpful across a wide variety of problems. In this\n",
            "chapter, rather than focusing on the programming details, we will instead focus on algorithms and the ideas\n",
            "behind them.\n",
            "Understanding Data Structures\n",
            "For many real-world problems, the ability to design an algorithm depends on how the data is represented. A\n",
            "data structure is a complex data type with two equally important parts:\n",
            "1. a specific representation or way of organizing a collection of more than one element, which is an\n",
            "individual value or data point, and\n",
            "2. a specific functionality or operations such as adding, retrieving, and removing elements.\n",
            "In our previous example, a string is a data structure for representing sentences as a sequence of characters. It\n",
            "has specific functionality such as character insertion or deletion, string concatenation, and string comparison.\n",
            "92 3 • Data Structures and Algorithms\n",
            "Access for free at openstax.orgAlthough the values for complex data are often diverse, computer scientists have designed data structures so\n",
            "that they can be reused for other problems. For example, rather than designing a specialized data structure\n",
            "for sentences in every human language, we often use a single, universal string data structure to represent\n",
            "sentences, including characters from different languages in the same sentence. (We will later see some\n",
            "drawbacks of generalizing assumptions in the design of data structures and algorithms.) In addition,\n",
            "computers take time to execute algorithms, so computer scientists are concerned about efficiency in terms of\n",
            "how long an algorithm takes to compute a result.\n",
            "Among the different types of universal data structures, computer scientists have found it helpful to categorize\n",
            "data structures according to their functionality without considering their specific representation. An abstract\n",
            "data type (ADT) consists of all data structures that share common functionality but differ in specific\n",
            "representation.\n",
            "Common abstract data types for complex data follow, and list and set types are shown in Figure 3.2. We will\n",
            "discuss each abstract data type in more detail together with their data structure implementations.\n",
            "• A list represents an ordered sequence of elements and allows adding, retrieving, and removing elements\n",
            "from any position in the list. Lists are indexed because they allow access to elements by referring to the\n",
            "element's index, which is the position or address for an element in the list. For example, a list can be used\n",
            "to represent a to-do list, where each item in the list is the next task to be completed in chronological order.\n",
            "• A set represents an unordered collection of unique elements and allows adding, retrieving, and removing\n",
            "elements from the set. Sets typically offer less functionality than lists, but this reduction in functionality\n",
            "allows for more efficient data structure representations. For example, a set can be used to represent the\n",
            "names of all the places that you want to visit in the future.\n",
            "• A map represents unordered associations between key-value pairs of elements, where each key can only\n",
            "appear once in the map. A map is also known as a dictionary since each term (key) has an associated\n",
            "definition (value). Maps are often used i\n",
            "Cited Pages: 101, 102, 103\n",
            "\n",
            "Snippet 13:\n",
            "Relate data structures and abstract data types\n",
            "• Select the data structure that is appropriate to solve a given problem practically\n",
            "Data Structures and Algorithms\n",
            "3Computer science is the study of computers and computational systems that involve data representation and\n",
            "process automation. Owing to their historical roots as calculators, computers can easily represent numerical\n",
            "data. Calculators rely on algorithms to add, subtract, multiply, and divide numbers. But what about more\n",
            "complex data? How do computers represent complex objects like graphs, images, videos, or sentences? What\n",
            "complications arise when we represent or process data in certain ways? These are some of the foundational\n",
            "questions that computer scientists and programmers focus on when designing software and applications that\n",
            "we use to solve problems.\n",
            "A data type determines how computers process data by defining the possible values for data and the possible\n",
            "functionality or operations on that data. For example, the integer data type is defined as values from a certain\n",
            "range of positive or negative whole numbers with functionality including addition, subtraction, multiplication,\n",
            "and division. The string data type is defined as a sequence of characters where each character can be a letter,\n",
            "digit, punctuation, or space, with functionalities that include adding or deleting a character from a string,\n",
            "concatenating strings, and comparing two strings based, for example, on their alphabetical order.\n",
            "Data types like strings are an example of abstraction, the process of simplifying a concept in order to\n",
            "represent it in a computer. The string data type takes a complex concept like a sentence and represents it in\n",
            "terms of more basic data that a computer can work with. When a computer compares two strings, it is really\n",
            "comparing the individual numerical character codes (see Chapter 5 Hardware Realizations of Algorithms:\n",
            "Computer Systems Design) corresponding to each pair of characters within the two strings.\n",
            "In this section, we will learn how to solve problems by choosing abstractions for complex data. We will see that\n",
            "just as our data grows more complex, so do our algorithms.\n",
            "Introduction to Algorithms\n",
            "An algorithm is a sequence of precise instructions that operate on data. We can think of recipes, plans, or\n",
            "instructions from our daily lives as examples of algorithms. Computers can only execute a finite pre-defined\n",
            "set of instructions exactly as instructed, which is why programming can feel like such a different way of\n",
            "communicating as compared to our natural human languages. A program is an implementation (realization)\n",
            "of an algorithm written in a formal programming language.\n",
            "Although each programming language is different from all the others, there are still common ideas across all\n",
            "of them. Knowing just a few of these common ideas enables computer scientists to address a wide variety of\n",
            "problems without having to start from scratch every single time. For example, the abstraction of string data\n",
            "enables programmers to write programs that operate on human-readable letters, digits, punctuation, or\n",
            "spaces without having to determine how to delve into each of these concepts. Programming languages allow\n",
            "us to define abstractions for representing ideas in a computer (see Chapter 4 Linguistic Realization of\n",
            "Algorithms: Low-Level Programming Languages for more).\n",
            "The study of data structures and algorithms focuses on identifying what is known as a canonical algorithm: a\n",
            "well-known algorithm that showcases design principles helpful across a wide variety of problems. In this\n",
            "chapter, rather than focusing on the programming details, we will instead focus on algorithms and the ideas\n",
            "behind them.\n",
            "Understanding Data Structures\n",
            "For many real-world problems, the ability to design an algorithm depends on how the data is represented. A\n",
            "data structure is a complex data type with two equally important parts:\n",
            "1. a specific representation or way of organizing a collection of more than one element, which is an\n",
            "individual value or data point, and\n",
            "2. a specific functionality or operations such as adding, retrieving, and removing elements.\n",
            "In our previous example, a string is a data structure for representing sentences as a sequence of characters. It\n",
            "has specific functionality such as character insertion or deletion, string concatenation, and string comparison.\n",
            "92 3 • Data Structures and Algorithms\n",
            "Access for free at openstax.orgAlthough the values for complex data are often diverse, computer scientists have designed data structures so\n",
            "that they can be reused for other problems. For example, rather than designing a specialized data structure\n",
            "for sentences in every human language, we often use a single, universal string data structure to represent\n",
            "sentences, including characters from different languages in the same sentence. (We will later see some\n",
            "drawbacks of generalizing assumptions in the design of data structures and algorithms.) In addition,\n",
            "computers take time to execute algorithms, so computer scientists are concerned about efficiency in terms of\n",
            "how long an algorithm takes to compute a result.\n",
            "Among the different types of universal data structures, computer scientists have found it helpful to categorize\n",
            "data structures according to their functionality without considering their specific representation. An abstract\n",
            "data type (ADT) consists of all data structures that share common functionality but differ in specific\n",
            "representation.\n",
            "Common abstract data types for complex data follow, and list and set types are shown in Figure 3.2. We will\n",
            "discuss each abstract data type in more detail together with their data structure implementations.\n",
            "• A list represents an ordered sequence of elements and allows adding, retrieving, and removing elements\n",
            "from any position in the list. Lists are indexed because they allow access to elements by referring to the\n",
            "element's index, which is the position or address for an element in the list. For example, a list can be used\n",
            "to represent a to-do list, where each item in the list is the next task to be completed in chronological order.\n",
            "• A set represents an unordered collection of unique elements and allows adding, retrieving, and removing\n",
            "elements from the set. Sets typically offer less functionality than lists, but this reduction in functionality\n",
            "allows for more efficient data structure representations. For example, a set can be used to represent the\n",
            "names of all the places that you want to visit in the future.\n",
            "• A map represents unordered associations between key-value pairs of elements, where each key can only\n",
            "appear once in the map. A map is also known as a dictionary since each term (key) has an associated\n",
            "definition (value). Maps are often used i\n",
            "Cited Pages: 101, 102, 103\n",
            "\n",
            "Snippet 14:\n",
            "the medical system, the algorithm designer emphasized physical characteristics of people that were\n",
            "deemed important and chose to ignore other characteristics, such as political views, which were deemed less\n",
            "important for the model.\n",
            "If an algorithm is a solution to a problem, then the model is the frame through which the algorithm designer\n",
            "defines the rules and potential outcomes. Without models, algorithm designers would struggle with the\n",
            "infinite complexity and richness of the world. Imagine, for example, designing a medical system that models\n",
            "patients at the level of individual atoms. This model offers a detailed representation of each patient in the\n",
            "most physical or literal sense. But this model is impractical because we do not know how particular\n",
            "configurations and collections of atoms contribute to a person’s overall health. Compared to this atomic-scale\n",
            "model, our former model consisting of age, sex, weight, and other physical characteristics is more practical for\n",
            "designing algorithms, but necessarily involves erasing our individual humanity to draw certain conclusions.\n",
            "In order to design algorithms, we need to be able to focus on relevant information rather than detailed\n",
            "representations of the real world. Further, computer science requires a philosophical mind to aid in problem\n",
            "solving. According to Brian Cantwell Smith, philosopher and cognitive and computer scientist, “Though this is\n",
            "not the place for metaphysics, it would not be too much to say that every act of conceptualization, analysis, or\n",
            "categorization, does a certain amount of violence to its subject matter, in order to get at the underlying\n",
            "regularities that group things together.”1 Without performing this “violence,” there would be too many details\n",
            "to wade through to create a useful algorithm.\n",
            "The relationship between algorithms, the software they empower, and the social outcomes they produce is\n",
            "currently the center of contested social and political debate. For example, all media platforms (e.g., Netflix,\n",
            "Hulu, and others) use some level of targeted advertising based on user preferences in order to recommend\n",
            "1 B. C. Smith, “The limits of correctness.” ACM SIGCAS Comput. Soc., vol. 14, 15, no. 1, 2, 3, 4, pp. 18-26, Jan. 1985. https://doi.org/\n",
            "10.1145/379486.379512.\n",
            "3.2 • Algorithm Design and Discovery 101specific movies or shows to their users. Users may not want their information to be used in this way, but there\n",
            "must be some degree of compromise to make these platforms attractive and useful to people.\n",
            "On the one hand, the technical definition of an algorithm is that it represents complex processes as a\n",
            "sequence of precise instructions operating on data. This definition does not overtly suggest how algorithms\n",
            "encode social outcomes. On the other hand, computer programs are human-designed and socially\n",
            "engineered. Algorithm designers simplify complex real-world problems by removing details so that they can be\n",
            "modeled as computational problems. Because software encodes and automates human ideas with computers,\n",
            "software engineers wield immense power through their algorithms.\n",
            "To further complicate the matter, software engineering is often a restrictive and formal discipline. Problem\n",
            "modeling is constrained by the model of computation, or the rules of the underlying computer that is\n",
            "ultimately responsible for executing the algorithm. Historically, computer science grew from its foundations in\n",
            "mathematics and formal logics, so algorithms were specialized to solve specific problems with a modest model\n",
            "of the underlying phenomena. This approach to algorithm design solves certain types of problems so long as\n",
            "they can be reasonably reduced to models that operate on a modest number of variables—ho wever many\n",
            "variables the algorithm designer can keep in mind. In the case of the medical system, the algorithm designer\n",
            "identified certain characteristics as particularly useful for computing a result.\n",
            "But there are many other problems that defy this approach, particularly tasks that involve subtle and often\n",
            "unconscious use of human sensory and cognitive faculties. An example of this is facial recognition. If asked to\n",
            "describe how we recognize a particular person’s face, an algorithm designer would be challenged to identify\n",
            "specific variables or combinations of variables that correspond to only a single person. The formal logic\n",
            "required to define an algorithm is strict and absolute, whereas our understanding human faces is defined by\n",
            "many subtle factors that are difficult for anyone to express using formal logic.\n",
            "INDUSTRY SPOTLIGHT\n",
            "Machine Learning Algorithms\n",
            "A machine learning algorithm addresses these kinds of problems by using an alternative model of\n",
            "computation, one that focuses on generalized algorithms designed to solve problems with a massive model\n",
            "of the underlying phenomena. Instead of attempting to identify a few key variables for facial recognition,\n",
            "for instance, machine learning algorithms can take as input a digital image represented as a rectangular\n",
            "grid of colored pixels. While each pixel in the image offers very little information about the person in mind,\n",
            "the facial features unique to each human arise from the arrangements and patterns of pixels that result\n",
            "from seeing many images of the same person.\n",
            "Think about the way your Apple iPhone or Google Pixel phone may look at you when you try to access it\n",
            "and have facial recognition enabled. The algorithm is not going to try to match your face to a saved picture\n",
            "of you because it would not work all the time if you do not look exactly like you did in the picture. Rather, it\n",
            "uses machine learning to extract patterns out of a person's face and match them, making it possible to\n",
            "recognize people all the time even if they are wearing glasses but was not wearing them when they set up\n",
            "facial recognition on their phone. This method does seem to mimic the way humans recognize people, even\n",
            "if they have not seen them for decades.\n",
            "Machine learning algorithms offer a more robust approach to modeling these kinds of problems that are\n",
            "not easily expressed in formal logic. But in this chapter, we focus on the earlier, classical perspective on\n",
            "algorithmic problem-solving with the end goal of designing specialized algorithms to solve problems with\n",
            "modest models of the underlying phenomena.\n",
            "102 3 • Data Structures and Algorithms\n",
            "Access for free at openstax.orgSearch Algorithms\n",
            "In computer science, searching is the problem of retrieving a target element from a collection that contains\n",
            "many elements. There are many ways to understand search algorithms; depending on the exact context of the\n",
            "problem and the input data, the expected output might differ. For example, suppose we want to find the target\n",
            "term in a dictionary that contains thousands or millions of terms and their assoc\n",
            "Cited Pages: 111, 112, 113\n",
            "\n",
            "Snippet 15:\n",
            "m designer emphasized physical characteristics of people that were\n",
            "deemed important and chose to ignore other characteristics, such as political views, which were deemed less\n",
            "important for the model.\n",
            "If an algorithm is a solution to a problem, then the model is the frame through which the algorithm designer\n",
            "defines the rules and potential outcomes. Without models, algorithm designers would struggle with the\n",
            "infinite complexity and richness of the world. Imagine, for example, designing a medical system that models\n",
            "patients at the level of individual atoms. This model offers a detailed representation of each patient in the\n",
            "most physical or literal sense. But this model is impractical because we do not know how particular\n",
            "configurations and collections of atoms contribute to a person’s overall health. Compared to this atomic-scale\n",
            "model, our former model consisting of age, sex, weight, and other physical characteristics is more practical for\n",
            "designing algorithms, but necessarily involves erasing our individual humanity to draw certain conclusions.\n",
            "In order to design algorithms, we need to be able to focus on relevant information rather than detailed\n",
            "representations of the real world. Further, computer science requires a philosophical mind to aid in problem\n",
            "solving. According to Brian Cantwell Smith, philosopher and cognitive and computer scientist, “Though this is\n",
            "not the place for metaphysics, it would not be too much to say that every act of conceptualization, analysis, or\n",
            "categorization, does a certain amount of violence to its subject matter, in order to get at the underlying\n",
            "regularities that group things together.”1 Without performing this “violence,” there would be too many details\n",
            "to wade through to create a useful algorithm.\n",
            "The relationship between algorithms, the software they empower, and the social outcomes they produce is\n",
            "currently the center of contested social and political debate. For example, all media platforms (e.g., Netflix,\n",
            "Hulu, and others) use some level of targeted advertising based on user preferences in order to recommend\n",
            "1 B. C. Smith, “The limits of correctness.” ACM SIGCAS Comput. Soc., vol. 14, 15, no. 1, 2, 3, 4, pp. 18-26, Jan. 1985. https://doi.org/\n",
            "10.1145/379486.379512.\n",
            "3.2 • Algorithm Design and Discovery 101specific movies or shows to their users. Users may not want their information to be used in this way, but there\n",
            "must be some degree of compromise to make these platforms attractive and useful to people.\n",
            "On the one hand, the technical definition of an algorithm is that it represents complex processes as a\n",
            "sequence of precise instructions operating on data. This definition does not overtly suggest how algorithms\n",
            "encode social outcomes. On the other hand, computer programs are human-designed and socially\n",
            "engineered. Algorithm designers simplify complex real-world problems by removing details so that they can be\n",
            "modeled as computational problems. Because software encodes and automates human ideas with computers,\n",
            "software engineers wield immense power through their algorithms.\n",
            "To further complicate the matter, software engineering is often a restrictive and formal discipline. Problem\n",
            "modeling is constrained by the model of computation, or the rules of the underlying computer that is\n",
            "ultimately responsible for executing the algorithm. Historically, computer science grew from its foundations in\n",
            "mathematics and formal logics, so algorithms were specialized to solve specific problems with a modest model\n",
            "of the underlying phenomena. This approach to algorithm design solves certain types of problems so long as\n",
            "they can be reasonably reduced to models that operate on a modest number of variables—however many\n",
            "variables the algorithm designer can keep in mind. In the case of the medical system, the algorithm designer\n",
            "identified certain characteristics as particularly useful for computing a result.\n",
            "But there are many other problems that defy this approach, particularly tasks that involve subtle and often\n",
            "unconscious use of human sensory and cognitive faculties. An example of this is facial recognition. If asked to\n",
            "describe how we recognize a particular person’s face, an algorithm designer would be challenged to identify\n",
            "specific variables or combinations of variables that correspond to only a single person. The formal logic\n",
            "required to define an algorithm is strict and absolute, whereas our understanding human faces is defined by\n",
            "many subtle factors that are difficult for anyone to express using formal logic.\n",
            "INDUSTRY SPOTLIGHT\n",
            "Machine Learning Algorithms\n",
            "A machine learning algorithm addresses these kinds of problems by using an alternative model of\n",
            "computation, one that focuses on generalized algorithms designed to solve problems with a massive model\n",
            "of the underlying phenomena. Instead of attempting to identify a few key variables for facial recognition,\n",
            "for instance, machine learning algorithms can take as input a digital image represented as a rectangular\n",
            "grid of colored pixels. While each pixel in the image offers very little information about the person in mind,\n",
            "the facial features unique to each human arise from the arrangements and patterns of pixels that result\n",
            "from seeing many images of the same person.\n",
            "Think about the way your Apple iPhone or Google Pixel phone may look at you when you try to access it\n",
            "and have facial recognition enabled. The algorithm is not going to try to match your face to a saved picture\n",
            "of you because it would not work all the time if you do not look exactly like you did in the picture. Rather, it\n",
            "uses machine learning to extract patterns out of a person's face and match them, making it possible to\n",
            "recognize people all the time even if they are wearing glasses but was not wearing them when they set up\n",
            "facial recognition on their phone. This method does seem to mimic the way humans recognize people, even\n",
            "if they have not seen them for decades.\n",
            "Machine learning algorithms offer a more robust approach to modeling these kinds of problems that are\n",
            "not easily expressed in formal logic. But in this chapter, we focus on the earlier, classical perspective on\n",
            "algorithmic problem-solving with the end goal of designing specialized algorithms to solve problems with\n",
            "modest models of the underlying phenomena.\n",
            "102 3 • Data Structures and Algorithms\n",
            "Access for free at openstax.orgSearch Algorithms\n",
            "In computer science, searching is the problem of retrieving a target element from a collection that contains\n",
            "many elements. There are many ways to understand search algorithms; depending on the exact context of the\n",
            "problem and the input data, the expected output might differ. For example, suppose we want to find the target\n",
            "term in a dictionary that contains thousands\n",
            "Cited Pages: 111, 112, 113\n",
            "\n",
            "Snippet 16:\n",
            "m designer emphasized physical characteristics of people that were\n",
            "deemed important and chose to ignore other characteristics, such as political views, which were deemed less\n",
            "important for the model.\n",
            "If an algorithm is a solution to a problem, then the model is the frame through which the algorithm designer\n",
            "defines the rules and potential outcomes. Without models, algorithm designers would struggle with the\n",
            "infinite complexity and richness of the world. Imagine, for example, designing a medical system that models\n",
            "patients at the level of individual atoms. This model offers a detailed representation of each patient in the\n",
            "most physical or literal sense. But this model is impractical because we do not know how particular\n",
            "configurations and collections of atoms contribute to a person’s overall health. Compared to this atomic-scale\n",
            "model, our former model consisting of age, sex, weight, and other physical characteristics is more practical for\n",
            "designing algorithms, but necessarily involves erasing our individual humanity to draw certain conclusions.\n",
            "In order to design algorithms, we need to be able to focus on relevant information rather than detailed\n",
            "representations of the real world. Further, computer science requires a philosophical mind to aid in problem\n",
            "solving. According to Brian Cantwell Smith, philosopher and cognitive and computer scientist, “Though this is\n",
            "not the place for metaphysics, it would not be too much to say that every act of conceptualization, analysis, or\n",
            "categorization, does a certain amount of violence to its subject matter, in order to get at the underlying\n",
            "regularities that group things together.”1 Without performing this “violence,” there would be too many details\n",
            "to wade through to create a useful algorithm.\n",
            "The relationship between algorithms, the software they empower, and the social outcomes they produce is\n",
            "currently the center of contested social and political debate. For example, all media platforms (e.g., Netflix,\n",
            "Hulu, and others) use some level of targeted advertising based on user preferences in order to recommend\n",
            "1 B. C. Smith, “The limits of correctness.” ACM SIGCAS Comput. Soc., vol. 14, 15, no. 1, 2, 3, 4, pp. 18-26, Jan. 1985. https://doi.org/\n",
            "10.1145/379486.379512.\n",
            "3.2 • Algorithm Design and Discovery 101specific movies or shows to their users. Users may not want their information to be used in this way, but there\n",
            "must be some degree of compromise to make these platforms attractive and useful to people.\n",
            "On the one hand, the technical definition of an algorithm is that it represents complex processes as a\n",
            "sequence of precise instructions operating on data. This definition does not overtly suggest how algorithms\n",
            "encode social outcomes. On the other hand, computer programs are human-designed and socially\n",
            "engineered. Algorithm designers simplify complex real-world problems by removing details so that they can be\n",
            "modeled as computational problems. Because software encodes and automates human ideas with computers,\n",
            "software engineers wield immense power through their algorithms.\n",
            "To further complicate the matter, software engineering is often a restrictive and formal discipline. Problem\n",
            "modeling is constrained by the model of computation, or the rules of the underlying computer that is\n",
            "ultimately responsible for executing the algorithm. Historically, computer science grew from its foundations in\n",
            "mathematics and formal logics, so algorithms were specialized to solve specific problems with a modest model\n",
            "of the underlying phenomena. This approach to algorithm design solves certain types of problems so long as\n",
            "they can be reasonably reduced to models that operate on a modest number of variables—however many\n",
            "variables the algorithm designer can keep in mind. In the case of the medical system, the algorithm designer\n",
            "identified certain characteristics as particularly useful for computing a result.\n",
            "But there are many other problems that defy this approach, particularly tasks that involve subtle and often\n",
            "unconscious use of human sensory and cognitive faculties. An example of this is facial recognition. If asked to\n",
            "describe how we recognize a particular person’s face, an algorithm designer would be challenged to identify\n",
            "specific variables or combinations of variables that correspond to only a single person. The formal logic\n",
            "required to define an algorithm is strict and absolute, whereas our understanding human faces is defined by\n",
            "many subtle factors that are difficult for anyone to express using formal logic.\n",
            "INDUSTRY SPOTLIGHT\n",
            "Machine Learning Algorithms\n",
            "A machine learning algorithm addresses these kinds of problems by using an alternative model of\n",
            "computation, one that focuses on generalized algorithms designed to solve problems with a massive model\n",
            "of the underlying phenomena. Instead of attempting to identify a few key variables for facial recognition,\n",
            "for instance, machine learning algorithms can take as input a digital image represented as a rectangular\n",
            "grid of colored pixels. While each pixel in the image offers very little information about the person in mind,\n",
            "the facial features unique to each human arise from the arrangements and patterns of pixels that result\n",
            "from seeing many images of the same person.\n",
            "Think about the way your Apple iPhone or Google Pixel phone may look at you when you try to access it\n",
            "and have facial recognition enabled. The algorithm is not going to try to match your face to a saved picture\n",
            "of you because it would not work all the time if you do not look exactly like you did in the picture. Rather, it\n",
            "uses machine learning to extract patterns out of a person's face and match them, making it possible to\n",
            "recognize people all the time even if they are wearing glasses but was not wearing them when they set up\n",
            "facial recognition on their phone. This method does seem to mimic the way humans recognize people, even\n",
            "if they have not seen them for decades.\n",
            "Machine learning algorithms offer a more robust approach to modeling these kinds of problems that are\n",
            "not easily expressed in formal logic. But in this chapter, we focus on the earlier, classical perspective on\n",
            "algorithmic problem-solving with the end goal of designing specialized algorithms to solve problems with\n",
            "modest models of the underlying phenomena.\n",
            "102 3 • Data Structures and Algorithms\n",
            "Access for free at openstax.orgSearch Algorithms\n",
            "In computer science, searching is the problem of retrieving a target element from a collection that contains\n",
            "many elements. There are many ways to understand search algorithms; depending on the exact context of the\n",
            "problem and the input data, the expected output might differ. For example, suppose we want to find the target\n",
            "term in a dictionary that contains thousands\n",
            "Cited Pages: 111, 112, 113\n"
          ]
        }
      ],
      "source": [
        "tool_output = ask_textbook_assistant.invoke(\"Algorithms\")\n",
        "print(tool_output)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 119,
      "metadata": {},
      "outputs": [
        {
          "data": {
            "text/plain": [
              "[{'name': 'ask_textbook_subagent_tool',\n",
              "  'args': {'subquery': 'understanding algorithms, their functionality, and how they operate in computer science'},\n",
              "  'id': 'call_LZ1ZMyUesJY4UUIfUnvvN9yN',\n",
              "  'type': 'tool_call'}]"
            ]
          },
          "execution_count": 119,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "from langchain.chat_models import init_chat_model\n",
        "\n",
        "llm = init_chat_model(\"openai:gpt-4o-mini\", temperature=0.0)\n",
        "llm_with_tools = llm.bind_tools([ask_textbook_assistant], tool_choice=\"required\")\n",
        "\n",
        "llm_with_tools.invoke(\"rewrite this query with more keywords so it can be better for searching: understanding algos and how they work\").tool_calls"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### Making our data classes\n",
        "\n",
        "To make building our application a bit easier, we'll create some classes that'll help us structure our Graph a bit more.\n",
        "\n",
        "We create a StudyGuide and ConceptGuide class, so that we can eventually call an LLM with structured generation to enforce adherence to our desired study guide format.\n",
        "\n",
        "And, we'll create a ContextFeedback class that allows us to enforce how we want our feedback LLM to response.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 120,
      "metadata": {},
      "outputs": [],
      "source": [
        "from pydantic import BaseModel, Field\n",
        "from typing import List, Literal\n",
        "\n",
        "class ConceptGuide(BaseModel):\n",
        "    concept_name: str = Field(description=\"The name of the concept to be studied\")\n",
        "    concept_description: str = Field(description=\"A description of the concept to be studied\")\n",
        "    cited_pages: list[str] = Field(description=\"The pages of the textbook that are relevant to the concept\")\n",
        "\n",
        "\n",
        "class StudyGuide(BaseModel):\n",
        "    original_query: str = Field(description=\"The original query that the user made\")\n",
        "    study_guide: List[ConceptGuide] = Field(description=\"A list of concepts to be studied by the user that pertain to the original query\")\n",
        "\n",
        "\n",
        "class ContextFeedback(BaseModel):\n",
        "    grade: Literal[\"Pass\", \"Rewrite\", \"More Context\"] = Field(description=\"Grade: Pass (good enough), Rewrite (has content but needs improvement), More Context (needs additional information)\")\n",
        "    feedback: str = Field(description=\"A few sentences of feedback on the study guide\")\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### Initial Graph Setup and LLMs\n",
        "\n",
        "Next, we'll setup our State and our LLMs, which are the workhorses for our application.\n",
        "\n",
        "\n",
        "Our State will describe the information that will persist inbetween each node/edge movement. It'll store information that we'll reference between these nodes to build our study guide.\n",
        "\n",
        "You may notice that we don't use the Messages component of LangGraph as much as we could. We do this to make it easier to understand what information is being stored where, but you may use the messages list instead to your preference.\n",
        "\n",
        "We'll also instantiate some LLMs: one to generate our queries and tool calls, one to generate our structured study guides, and one to provide feedback!\n",
        "\n",
        "We choose a more powerful LLM to provide feedback, as to optimize our token use on the computation that may be the most difficult. And, the Class we made above will help to reduce token generation as well, enforcing the LLM to response one of three grades and a short text on feedback.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 121,
      "metadata": {},
      "outputs": [],
      "source": [
        "\n",
        "from langgraph.graph import StateGraph\n",
        "from langchain.chat_models import init_chat_model\n",
        "from typing_extensions import TypedDict\n",
        "from langgraph.graph.message import add_messages\n",
        "from typing import  List, Annotated\n",
        "from operator import add\n",
        "\n",
        "\n",
        "class State(TypedDict):\n",
        "    grade: str = None\n",
        "    feedback: Annotated[List[str], add]\n",
        "    study_guide: StudyGuide\n",
        "    original_query: str\n",
        "    # this allows us to continually add context\n",
        "    retrieved_context: Annotated[List[str], add]\n",
        "    # we should have new queries as well here\n",
        "    new_query: Annotated[List[str], add]\n",
        "    num_iterations: int = 0\n",
        "    messages: Annotated[list, add_messages]\n",
        "\n",
        "\n",
        "graph_builder = StateGraph(State)\n",
        "\n",
        "# Fix tools, and teach LLM to use tools\n",
        "llm = init_chat_model(\"openai:gpt-4o-mini\", temperature=0.0)\n",
        "llm_with_tools = llm.bind_tools([ask_textbook_assistant], tool_choice=\"required\")\n",
        "# instance to generate study guide\n",
        "study_guide_maker_llm = init_chat_model(\"openai:gpt-4o-mini\", temperature=0.0)\n",
        "study_guide_maker = study_guide_maker_llm.with_structured_output(StudyGuide)\n",
        "\n",
        "# setup feedback llm\n",
        "#o4-mini works well too\n",
        "feedback_llm_instance = init_chat_model(\"openai:gpt-4.1\", temperature=0.0)\n",
        "feedback_llm = feedback_llm_instance.with_structured_output(ContextFeedback)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### Building Nodes\n",
        "\n",
        "Next, we'll build the nodes we described above. These will be functions that take in a State, and output changes to the state.\n",
        "\n",
        "#### Query Generator"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 122,
      "metadata": {},
      "outputs": [],
      "source": [
        "def query_generator_and_call(state: State):\n",
        "\n",
        "    '''\n",
        "        Handles writing queries and issuing tool call requests.\n",
        "\n",
        "        If the user has started the chain, use the most recent message as the prompt for the query\n",
        "\n",
        "        If we've already tried to generate a query, and we need a new one, regenerate a query\n",
        "    '''\n",
        "\n",
        "    original_query = state.get(\"original_query\", \"\")\n",
        "    messages = state.get(\"messages\", [])\n",
        "\n",
        "    if not original_query:\n",
        "        # First time: pull the last message from the messages list as the original query\n",
        "        original_query = messages[-1].content\n",
        "        prompt = (\n",
        "            f\"\"\"You are an expert at searching over an introductory computer science textbook. \n",
        "            Given an original query from a user about computer science topics, \n",
        "            your job is to generate a single, more specific and detailed search query \n",
        "            that will help retrieve the most relevant information from the textbook. F\n",
        "            ocus on clarifying the user's intent and making the query as effective as possible \n",
        "            for searching an intro CS textbook.\n",
        "\n",
        "            The query will be passed to a tool that will retrieve context from the textbook.\n",
        "            \n",
        "            Here is the original query:\n",
        "            {original_query}\n",
        "\"\"\"\n",
        "        )\n",
        "\n",
        "        # This calls the llm with knowledge of the tools, and we get the tool call back\n",
        "        new_query = llm_with_tools.invoke(prompt).tool_calls[0][\"args\"][\"subquery\"]\n",
        "        \n",
        "        # call tool, with the specified new query\n",
        "        returned_context = ask_textbook_assistant.invoke(new_query)\n",
        "\n",
        "        return {\n",
        "            \"new_query\": [new_query],\n",
        "            \"retrieved_context\": [returned_context],\n",
        "            \"original_query\": original_query,\n",
        "            \"messages\": [new_query]\n",
        "        }\n",
        "    else:\n",
        "        # We've already generated a query, and need to generate a new one (e.g., after feedback)\n",
        "\n",
        "        previous_queries = \"\\n\\n\".join([f\"Attempt {i+1}:\\n{q}\" for i, q in enumerate(state.get(\"new_query\", []))])\n",
        "        previous_retrieved_context = \"\\n\\n\".join([f\"Attempt {i+1}:\\n{ctx}\" for i, ctx in enumerate(state.get(\"retrieved_context\", []))])\n",
        "        grade = state.get(\"grade\", \"\")\n",
        "\n",
        "        # We get most recent feedback\n",
        "        feedback = state.get(\"feedback\", \"\")[-1]\n",
        "\n",
        "        prompt = f\"\"\"\n",
        "            You are an expert educational query generator.\n",
        "            You will be given an original query, which is the question or topic the user wants to study.\n",
        "            Please generate a new query that is more specific and detailed, based on the original query.\n",
        "\n",
        "            Here is the original query:\n",
        "            {original_query}\n",
        "\n",
        "            Here are the previous query requests:\n",
        "            {previous_queries}\n",
        "\n",
        "            Here are the previously retrieved context:\n",
        "            {previous_retrieved_context}\n",
        "\n",
        "            Here is the feedback on that context:\n",
        "            {feedback}\n",
        "\n",
        "            Here is the current grade of the study guide:\n",
        "            {grade}\n",
        "\n",
        "            Based on any feedback or the need for more detail, generate a single new, improved query, to find more or missing information.\n",
        "\"\"\"\n",
        "        new_query_response = llm_with_tools.invoke(prompt).tool_calls[0][\"args\"][\"subquery\"]\n",
        "\n",
        "        # call tool\n",
        "        returned_context = ask_textbook_assistant.invoke(new_query_response)\n",
        "\n",
        "        return {\n",
        "            \"new_query\": [new_query_response],\n",
        "            \"original_query\": original_query,\n",
        "            \"retrieved_context\": [returned_context],\n",
        "            \"messages\": messages\n",
        "        }\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "#### Study Guide Generator\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 123,
      "metadata": {},
      "outputs": [],
      "source": [
        "def study_guide_generator(state: State):\n",
        "    \"\"\"\n",
        "    This function uses an LLM to generate study guides based on user queries and feedback.\n",
        "\n",
        "    - If no feedback is provided, it generates a new study guide.\n",
        "    - If feedback is provided, rewrites the study guide based on the feedback.\n",
        "\n",
        "    \"\"\"\n",
        "\n",
        "    # check if feedback is provided\n",
        "    study_guide = state.get(\"study_guide\", [])\n",
        "    feedback = \"\\n\\n\".join([f\"Attempt {i+1}:\\n{f}\" for i, f in enumerate(state.get(\"feedback\", []))])\n",
        "    grade = state.get(\"grade\", \"\")\n",
        "\n",
        "    original_query = state.get(\"original_query\", \"\")\n",
        "    \n",
        "    retrieved_context = \"\\n\\n\".join([f\"Attempt {i+1}:\\n{ctx}\" for i, ctx in enumerate(state.get(\"retrieved_context\", []))])\n",
        "\n",
        "    if grade == None or study_guide == []:\n",
        "        # We haven't generated a study guide yet, or we haven't a grade.\n",
        "        prompt = f\"\"\"\n",
        "\n",
        "        You are an expert educational study guide generator.\n",
        "        You will be given a original query, which is the question or topic the user wants to study.\n",
        "        Please generate a study guide that is more specific and detailed, based on the original query.\n",
        "        Here is the original query:\n",
        "        {original_query}\n",
        "        Here is the retrieved context:\n",
        "        {retrieved_context}\n",
        "        \"\"\"\n",
        "        study_guide = study_guide_maker.invoke(prompt)\n",
        "\n",
        "        return {\"study_guide\": study_guide}\n",
        "    elif state.get(\"grade\") == \"Rewrite\":\n",
        "        # We've already generated a study guide, and need to generate a new one (e.g., after feedback)\n",
        "        previous_study_guide = \"\\n\\n\".join([f\"Attempt {i+1}:\\n{sg}\" for i, sg in enumerate(state.get(\"study_guide\", []))])\n",
        "        retrieved_context = \"\\n\\n\".join([f\"Attempt {i+1}:\\n{ctx}\" for i, ctx in enumerate(state.get(\"retrieved_context\", []))])\n",
        "        grade = state.get(\"grade\", \"\")\n",
        "        # We smash the feedback together separated by attempts\n",
        "        feedback = \"\\n\\n\".join([f\"Attempt {i+1}:\\n{f}\" for i, f in enumerate(state.get(\"feedback\", []))])\n",
        "\n",
        "        prompt = f\"\"\"\n",
        "        You are an expert educational study guide generator.\n",
        "        You will be given a original query, which is the question or topic the user wants to study.\n",
        "        Please rewrite the study guide that is more specific and detailed, based on the original query.\n",
        "        Here is the original query:\n",
        "        {original_query}\n",
        "        Here is the previous study guide:\n",
        "        {previous_study_guide}\n",
        "        Here is the previous retrieved context. This time, there is more context to work with.\n",
        "        {retrieved_context}\n",
        "        Here is the previous feedback on the study guide:\n",
        "        {feedback}\n",
        "        Here is the current grade of the study guide:\n",
        "        {grade}\n",
        "\n",
        "        Provide an new study guide that will be given to the user\n",
        "        \"\"\"\n",
        "\n",
        "        new_study_guide = study_guide_maker.invoke(prompt)\n",
        "\n",
        "        return {\"study_guide\": new_study_guide}\n",
        "    elif state.get(\"grade\") == \"More Context\":\n",
        "        # We've already generated a study guide, and need to generate a new one (e.g., after feedback)\n",
        "        previous_study_guide = \"\\n\\n\".join([f\"Attempt {i+1}:\\n{sg}\" for i, sg in enumerate(state.get(\"study_guide\", []))])\n",
        "        grade = state.get(\"grade\", \"\")\n",
        "        # We smash the feedback together separated by attempts\n",
        "        feedback = \"\\n\\n\".join([f\"Attempt {i+1}:\\n{f}\" for i, f in enumerate(state.get(\"feedback\", []))])\n",
        "\n",
        "        prompt = f\"\"\"\n",
        "        You are an expert educational study guide generator.\n",
        "        You will be given a original query, which is the question or topic the user wants to study.\n",
        "        Please generate a study guide that is more specific and detailed, based on the original query.\n",
        "        Here is the original query:\n",
        "        {original_query}\n",
        "        Here is the previous study guide:\n",
        "        {previous_study_guide}\n",
        "        Here is the previous retrieved context. This time, there is more context to work with.\n",
        "        {retrieved_context}\n",
        "        Here is the previous feedback on the study guide:\n",
        "        {feedback}\n",
        "        Here is the current grade of the study guide:\n",
        "        {grade}\n",
        "\n",
        "        Provide an new study guide that will be given to the user\n",
        "        \"\"\"\n",
        "\n",
        "        new_study_guide = study_guide_maker.invoke(prompt)\n",
        "\n",
        "        return {\"study_guide\": new_study_guide}\n",
        "    else:\n",
        "        # The study guide is Passed. We can return it.\n",
        "        return {\"study_guide\": study_guide}"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "#### Feedback Bot"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 124,
      "metadata": {},
      "outputs": [],
      "source": [
        "context_grade_description = '''\n",
        "\n",
        "A grade of whether or not the provided study guide is useful for the user's query.\n",
        "\n",
        "Always use the text within the returned context to grade the study guide. This is direct text from the book.\n",
        "\n",
        "In order to pass, the study guide MUST meet the following criteria:\n",
        "\n",
        "1. VARIETY: The guide must use at least 5 different sections of the book, graded by distinct page number groups. If the guide\n",
        "is supposed to represent multiple different topics, there must be multiple sections per topic to help student learning. Failures here mean we need more context.\n",
        "\n",
        "2. RELEVANCE: Each concept represented in the guide must be pertinent to the user's query. Failures here mean we need more context, or rewriting to better phrase existing concepts.\n",
        "\n",
        "3. NO HALLUCINATIONS: The study guide must clearly be referencing topics that EXIST in the book. Hallucinated topics are an automatic rewrite.\n",
        "\n",
        "4. LEARNING PATH:The study guide must provided a clear roadmap to achieving the result of the user's query. If information from the user's query\n",
        "is not available in the book at all, the guide must instruct the user to find that information elsewhere. Failures here mean we need more context, and possibly a rewrite.\n",
        "\n",
        "5. CONTEXTUAL KNOWLEDGE ONLY: The guide MUST NOT reference information that is NOT in the book. The guide is meant to be a companion for the book, so any \n",
        "invention of resources outside of the book is an automatic fail. This usually just means we need a rewrite.\n",
        "\n",
        "If a guide meets ALL criteria, the grade should be \"Pass\". Otherwise, the grade will fall into one of the following categories:\n",
        "\n",
        "\"Rewrite\": The retrieved context is sufficient for the query, but the study guide needs to be rewritten to meet the criteria.\n",
        "\n",
        "\"More Context\": The study guide structure is okay, but the concepts are not relevant to the query. More context needs to be found by searching a new query.\n",
        "\n",
        "Feedback must include what and why the grade is what it is. Be as strict as necessary. Please choose one of Pass, Rewrite or More Context. \n",
        "\n",
        "Iteration are allowed, so prioritize one of the grades if there are multiple possible options.\n",
        "\n",
        "'''\n",
        "\n",
        "\n",
        "def feedback_bot(state: State):\n",
        "    '''\n",
        "    Generates feedback on study guide, using described critera. Depending on feedback, is routed \n",
        "    to the study guide generator or the query generator.\n",
        "\n",
        "\n",
        "    '''\n",
        "    study_guide = state.get(\"study_guide\", \"\")\n",
        "\n",
        "    # We smash the context together separated by attempts\n",
        "    original_query = state.get(\"original_query\", \"\")\n",
        "    additional_queries = state.get(\"new_query\", [])\n",
        "    retrieved_context_list = state.get(\"retrieved_context\", [])\n",
        "    retrieved_context = \"\\n\\n\".join([f\"Attempt {i+1}:\\n{ctx}\" for i, ctx in enumerate(retrieved_context_list)])\n",
        "\n",
        "    prompt = f'''You are an expert educational evaluator. You will be provided a study guide,\n",
        "    which has been constructed from a textbook on computer science. You will also be passed the pages from the textbook,\n",
        "     which are being used to justify the readings for the study guide.\n",
        "\n",
        "     The query that prompted the study guide is:\n",
        "     {original_query}\n",
        "\n",
        "     The additional queries that were used to find the context are (may be empty):\n",
        "     {additional_queries}\n",
        "\n",
        "    Grade the study guide based on the associated criteria:\n",
        "\n",
        "    {context_grade_description}\n",
        "\n",
        "    You will return Pass, Rewrite, or More Context.\n",
        "\n",
        "    Rewrites are when no more information is necssary to be found, but the study guide needs more improvement.\n",
        "\n",
        "    More Context is when the context is not enough to complete the study guide, and the study guide needs more information from our book to be useful.\n",
        "\n",
        "    Pass is when the study guide meets all criteria.\n",
        "    \n",
        "    Here is the StudyGuide to evaluate:\\n{study_guide}\\n\n",
        "    \n",
        "    \n",
        "    Here is all the retrieved context:\\n{retrieved_context}\\n\n",
        "    Provide your grade, and feedback:\n",
        "'''\n",
        "\n",
        "    grade = feedback_llm.invoke(prompt)\n",
        "\n",
        "    return {\"grade\": grade.grade, \"feedback\": [grade.feedback], \"num_iterations\": state.get(\"num_iterations\", 0) + 1}"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 125,
      "metadata": {},
      "outputs": [
        {
          "data": {
            "text/plain": [
              "<langgraph.graph.state.StateGraph at 0x1332e1c50>"
            ]
          },
          "execution_count": 125,
          "metadata": {},
          "output_type": "execute_result"
        }
      ],
      "source": [
        "# Nowe we can construct the whole graph. First, we add all nodes\n",
        "from langgraph.graph import START, END\n",
        "\n",
        "# query generator and call\n",
        "graph_builder.add_edge(START, \"query_generator_and_call\")\n",
        "graph_builder.add_node(\"query_generator_and_call\", query_generator_and_call)\n",
        "# study guide generator\n",
        "graph_builder.add_node(\"study_guide_generator\", study_guide_generator)\n",
        "# feedback bot\n",
        "graph_builder.add_node(\"feedback_bot\", feedback_bot)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### Building Edges\n",
        "\n",
        "Finally, we'll build our edges, which determine how data flows between each node, where the application starts and ends!\n",
        "\n",
        "We'll need edges to connect nodes that we know will always flow, and conditional edges for routing to the appropriate node once we receive feedback.\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 126,
      "metadata": {},
      "outputs": [],
      "source": [
        "#wire query generator to the study guide\n",
        "graph_builder.add_edge(\"query_generator_and_call\", \"study_guide_generator\")\n",
        "\n",
        "# write study guide to feedback bot\n",
        "graph_builder.add_edge(\"study_guide_generator\", \"feedback_bot\")\n",
        "\n",
        "# Now, the conditionals. We write feedback bot to study guide generator, \n",
        "# and we write feedback bot to the query call, and the end.\n",
        "\n",
        "\n",
        "def feedback_iteration(state: State):\n",
        "    '''\n",
        "\n",
        "    Conditional function to direct state at feedbackbot to end, query, or study guide generator.\n",
        "\n",
        "    If the feedback bot determines the guide passes, we end.\n",
        "\n",
        "    If we need a rewrite, we go to the query generator and call.\n",
        "\n",
        "    If we need more context, we go to the study guide generator.\n",
        "    '''\n",
        "\n",
        "    grade = state.get(\"grade\", \"\")\n",
        "\n",
        "    if grade == \"Pass\":\n",
        "        return \"end\"\n",
        "    elif grade == \"Rewrite\":\n",
        "        return \"rewrite\"\n",
        "    elif grade == \"More Context\":\n",
        "        return \"more_context\"\n",
        "    else:\n",
        "        return \"end\"\n",
        "\n",
        "\n",
        "graph_builder.add_conditional_edges(\n",
        "    \"feedback_bot\",\n",
        "    feedback_iteration,\n",
        "    {\n",
        "        \"end\": END,\n",
        "        \"rewrite\": \"study_guide_generator\",\n",
        "        \"more_context\": \"query_generator_and_call\",\n",
        "    },\n",
        ")\n",
        "\n",
        "graph = graph_builder.compile()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 127,
      "metadata": {},
      "outputs": [],
      "source": [
        "### Drawing the Graph"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 131,
      "metadata": {},
      "outputs": [
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAV8AAAHgCAIAAACNS/l2AAAAAXNSR0IArs4c6QAAIABJREFUeJzs3WdcE1nXAPCbRgkt9F5EQUURRFRsKIKCYgFFccXeXRVsqy6WFcvaG7qorBUbdrAsKnbFhoUOKgKCUhQIJYGQ+n4Y3ywPjghswqSc/88PyWTKSQwn956ZuZckEokQAAB8h0x0AAAAGQXZAQCAD7IDAAAfZAcAAD7IDgAAfJAdAAD4qEQHAFpVTTWfWcKrqebXVAn4fJGALwfns1XVyTRVMl2LQtemGFmoER2OEiHB9Q7KoLKUl53Myk1l8/lCFTUyXYtK16ZoalP5PDn436fQSBVfuDXVAlU6ueBtbZvOGm27aFh31CA6LsUH2UHB1dUKnlwtY1fz9YxU2jhqmNqoEx3Rf1JTzc9NYxflcb7k1/Uerm/jADlCiiA7KLKkB8wXN5i9h+t37q1DdCwSVlZU9+RqGU2V5D3RhEQmER2OYoLsoLBuHC82tlLt6qFLdCBSVPKx9vyez4FLLA3NVYmORQFBdlBMl/Z+cuyrY9dVi+hAWkP0tvyh00219WhEB6JoIDsooDNb83sO1bPtrEl0IK3n7I6CviMNzNvJd1VF1sD1Dorm1oliF09dpUoNCKHAJZb/HC3isAVEB6JQoO2gUFIeVQh4oq4DFbnW8CPsKt7ds1+HzzQjOhDFAW0HxSHgix7HlipnakAIaWjTdI1U3txjEh2I4oDsoDieXCvtPcyA6CiI1Hu4/pOrZURHoTggOyiIGha/8ivPeQCD6ECIRCaT3EcbvL4LzQfJgOygIHJS2RracNcMMm9Lz3xRRXQUCgKyg4LITWW3cWzty4pXrFgRGxvb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at1eXm1WlPFLAubKEdF/lADIc6Xl4uTd7fXsUKoI6QDQ2beqPOzZqynxnJj08gvydn9ws5hzDgwCj06huwZiUYiRFnV3C7kf8gvq1GRIBpYhnRgy9GJpG0U8ysFtwtprPyy5q+Uxs7Xc9QDdYd0YM6ZqW5i6PJK0/Yg8j9Uv1k8NdntdiFQA+YdGPXiSU4rcPG02EzbhBzirC3JYsw5cgG9Bg9AOrBr5q366qnUmYkl+ujLnN4iLSi5b/Lhc8ldmGvwCKQD614/X/s+V/Jx/OZkuEFbrRtKyxkFSXdsqzcbGhmPu10O/AWkgweUDGvuo/71g65I5vpNSrzABwSeNOpSiH/C8X6rZNmmZZZthzjtKaF/MNI/FMGWJ89BOniJbRMlZ+qqrWuWVXHYfKWW431CC9faFgi38e2dgp9rnnmTjQbpAAB06OwBAB3SAQDokA4AQId0AAA6pAMA0CEdAIDuN2YPAQSt6EbuAAAAAElFTkSuQmCC",
            "text/plain": [
              "<IPython.core.display.Image object>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "from IPython.display import Image, display\n",
        "\n",
        "display(Image(graph.get_graph().draw_mermaid_png(max_retries=5)))"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 129,
      "metadata": {},
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "---\n",
            "config:\n",
            "  flowchart:\n",
            "    curve: linear\n",
            "---\n",
            "graph TD;\n",
            "\t__start__([<p>__start__</p>]):::first\n",
            "\tquery_generator_and_call(query_generator_and_call)\n",
            "\tstudy_guide_generator(study_guide_generator)\n",
            "\tfeedback_bot(feedback_bot)\n",
            "\t__end__([<p>__end__</p>]):::last\n",
            "\t__start__ --> query_generator_and_call;\n",
            "\tquery_generator_and_call --> study_guide_generator;\n",
            "\tstudy_guide_generator --> feedback_bot;\n",
            "\tfeedback_bot -. &nbsp;end&nbsp; .-> __end__;\n",
            "\tfeedback_bot -. &nbsp;rewrite&nbsp; .-> study_guide_generator;\n",
            "\tfeedback_bot -. &nbsp;more_context&nbsp; .-> query_generator_and_call;\n",
            "\tclassDef default fill:#f2f0ff,line-height:1.2\n",
            "\tclassDef first fill-opacity:0\n",
            "\tclassDef last fill:#bfb6fc\n",
            "\n"
          ]
        }
      ],
      "source": [
        "print(graph.get_graph().draw_mermaid())\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### Calling the Graph"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Now, we can invoke the whole graph together! Note that your output may vary from what is expected in the notebook, due to the nature of several LLM calls. This application is meant as a starting point and learning example. Feel free to adjust it for better results!"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 136,
      "metadata": {},
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Final output:\n",
            "\n",
            "=== Original Query ===\n",
            "I want to understand how computers work, I want to learn about web app development, and also algorithms. Make me a detailed guide for all three.\n",
            "\n",
            "=== Study Guide ===\n",
            "\n",
            "=== Study Guide ===\n",
            "concept_name='How Computers Work' concept_description='Understanding the fundamental components of computers, including hardware, software, and the principles of computation.' cited_pages=['23', '24', '25']\n",
            "\n",
            "=== Study Guide ===\n",
            "concept_name='Web Application Development' concept_description='An overview of web application frameworks, the differences between native, web, and hybrid applications, and the technologies involved in building modern web applications.' cited_pages=['585', '586', '587']\n",
            "\n",
            "=== Study Guide ===\n",
            "concept_name='Algorithms' concept_description='An introduction to algorithms, their design, and analysis, including common algorithmic problems and data structures used in computing.' cited_pages=['109', '110', '111']\n",
            "\n",
            "=== Retrieved Context ===\n",
            "['Snippet 1:\\nstry today. For example, mobile health\\r\\napplications have become quite popular. Smartwatches can collect health-related data using various\\r\\nsensors and mobile health applications can leverage that data to provide useful reports to users as they\\r\\nexercise. Using a native application framework provides quicker load times, smooth animations and\\r\\ntransitions, optimal security, and a seamless user experience, to make it easier to immediately track and\\r\\naccess health-care data.\\r\\nDrawbacks to using native application framework include a longer development process, increased cost,\\r\\ncomplex maintenance and updates, platform dependency, regulatory and compliance issues, and end-user\\r\\nbarriers.\\r\\nThe Benefits and Drawbacks Between Native, Web, and Hybrid Mobile Application\\r\\nDevelopment\\r\\nNative applications have the benefits of accessing device-specific hardware and sensors (e.g., camera,\\r\\naccelerometer), data (e.g., location, contacts), and are optimized for performance.\\r\\nHowever, they have the drawbacks of being device-dependent and available primarily through proprietary app\\r\\nstores (Google Play for Android and Apple’s App Store for iOS). Developers need to learn different languages\\r\\nand libraries for the devices. However, cross-platform development is possible with frameworks (e.g., Flutter,\\r\\nKotlin Multiplatform Mobile), allowing developers to code in a single language and run solutions on both\\r\\nplatforms.\\r\\nWeb apps can also run in a browser on mobile devices. They have the distinct advantage of responsiveness\\r\\nand can run on various screen sizes—thus allowing for a single codebase that can increase productivity and\\r\\nreduce cost. Disadvantages to web apps on mobile devices are limited access to hardware and software\\r\\nfeatures, lower performance than native apps, and web apps may perform differently depending on the\\r\\nmobile browser. Traditionally, web apps didn’t look like native apps. In 2017, Google introduced Progressive\\r\\nWeb Apps for Android, allowing web apps to look and feel similar to native apps.\\r\\nFinally, hybrid apps are web apps wrapped inside a native device framework (e.g., Apache Cordova). These\\r\\napps have the advantages of using traditional web application development while accessing and utilizing\\r\\ndevice functions and running on multiple mobile platforms. The drawbacks are reduced speed and potential\\r\\nsecurity vulnerabilities found in the framework.\\r\\n11.1 • Modern Web Applications Architectures 575CONCEPTS IN PRACTICE\\r\\nSoftware Patterns and Frameworks\\r\\nAs discussed in Chapter 9 Software Engineering and Chapter 10 Enterprise and Solution Architectures\\r\\nManagement, architectural styles, architectural patterns, and design patterns are typically used to enforce\\r\\nthe quality attributes of software solutions. To facilitate the creation and maintenance of web applications\\r\\nand scalable transactional websites, web application frameworks and native application frameworks that\\r\\nleverage applicable patterns, such as MVC, were created and improved over the past couple of decades.\\r\\nWeb frameworks are used within web application frameworks to facilitate the use of HTML5, CSS3, and\\r\\nJavaScript and to publish responsive web pages that can be rendered by modern browsers on all modern\\r\\ntarget devices. Web application frameworks help process UI-driven requests that result in publishing or\\r\\nupdating web pages. Native application frameworks take advantage of capabilities available on specific\\r\\ntarget devices such as iPhones and Android phones. Organizations in many industries rely on web\\r\\napplications and related frameworks to conduct business daily.\\r\\nWeb 3.0 Applications\\r\\nWeb 3.0 is the next phase of the Web. It is still being realized, and similar to Web 1.0 and 2.0, it can only be\\r\\nfully understood in hindsight. The technology and uses of the Web overlap between the phases, with newer\\r\\nphases becoming preferred over their predecessor phases. If Web 1.0 was the read-only web, and Web 2.0 was\\r\\nthe participation (write) web, then Web 3.0 may be the read, write, and execute web.\\r\\nTim Berners-Lee had referred to Web 3.0 as the Semantic Web, a system of autonomous agents, which are\\r\\nsoftware programs that respond to events. That model has shifted over the years. While AI (and other\\r\\ntechnologies such as AR/VR) will likely form a part of Web 3.0 or Web x.0, the principles that govern the next\\r\\nphase are expected to be around a web that is decentralized, permissionless, and trusted.\\r\\nWeb 3.0 sees a shift from the more traditional client-server model to a peer-to-peer networking model. A peer\\x02to-peer network is one in which devices connect and can share data and processing without needing a\\r\\ncentralized server. Peers in this scheme can perform the role of a traditional client, server, or both. This shift\\r\\nwill foster a trusted, decentralized, and open web, where large companies don’t own the data, but everyone\\r\\ncollectively owns it. Technologies such as a smart contract allow a trusted model that is needed in a\\r\\ndecentralized system. Artificial intelligence and machine learning will improve information access through\\r\\nunderstanding the meaning of content available on the Web. The exemplar apps of the Web 3.0 phase will be\\r\\ndefined in the future. Still, if the previous phases of the Web are any indication, it will fundamentally change\\r\\nhow we operate in an ever-evolving technological world.\\r\\nFinally, Web 3.0 apps will run on a web that supports Web 1.0 and 2.0 apps, with the likely result being hybrid\\r\\narchitectures that are partially Web 2.0 and 3.0.\\r\\nWeb 3.0 Application Architectures\\r\\nWeb 3.0 apps are architected without a centralized server, so they are considered to be decentralized Apps\\r\\n(DApps), which are applications that execute smart contracts and run over distributed ledger technology (DLT).\\r\\nSmart contracts are programs that can be executed on a distributed ledger. Distributed ledgers use\\r\\nindependent network nodes to record, share, and synchronize transactions in their respective electronic\\r\\nledgers instead of keeping them in a centralized server. The code is visible to all parties, and trust is put into\\r\\nthe code instead of a centralized third party. Distributed ledgers chronicle transactions between accounts that\\r\\nare recorded in multiple places. Blockchain is a type of DLT.\\r\\nLet’s compare a traditional Web 2.0 application with a 3.0 DApp. In Web 2.0, if you created a website for users\\r\\nto post pictures and make comments on them, you would need functionality for authenticating users,\\r\\n576 11 • Web Applications Development\\r\\nAccess for free at openstax.orgauthorizing their actions, generating a UI for adding images, browsing images, and posting comments. To do\\r\\nthis, you would need a front-end web server and back-end processing for business logic and data storage.\\r\\nThese servers would \\nCited Pages: 585, 586, 587\\n\\nSnippet 2:\\nstry today. For example, mobile health\\r\\napplications have become quite popular. Smartwatches can collect health-related data using various\\r\\nsensors and mobile health applications can leverage that data to provide useful reports to users as they\\r\\nexercise. Using a native application framework provides quicker load times, smooth animations and\\r\\ntransitions, optimal security, and a seamless user experience, to make it easier to immediately track and\\r\\naccess health-care data.\\r\\nDrawbacks to using native application framework include a longer development process, increased cost,\\r\\ncomplex maintenance and updates, platform dependency, regulatory and compliance issues, and end-user\\r\\nbarriers.\\r\\nThe Benefits and Drawbacks Between Native, Web, and Hybrid Mobile Application\\r\\nDevelopment\\r\\nNative applications have the benefits of accessing device-specific hardware and sensors (e.g., camera,\\r\\naccelerometer), data (e.g., location, contacts), and are optimized for performance.\\r\\nHowever, they have the drawbacks of being device-dependent and available primarily through proprietary app\\r\\nstores (Google Play for Android and Apple’s App Store for iOS). Developers need to learn different languages\\r\\nand libraries for the devices. However, cross-platform development is possible with frameworks (e.g., Flutter,\\r\\nKotlin Multiplatform Mobile), allowing developers to code in a single language and run solutions on both\\r\\nplatforms.\\r\\nWeb apps can also run in a browser on mobile devices. They have the distinct advantage of responsiveness\\r\\nand can run on various screen sizes—thus allowing for a single codebase that can increase productivity and\\r\\nreduce cost. Disadvantages to web apps on mobile devices are limited access to hardware and software\\r\\nfeatures, lower performance than native apps, and web apps may perform differently depending on the\\r\\nmobile browser. Traditionally, web apps didn’t look like native apps. In 2017, Google introduced Progressive\\r\\nWeb Apps for Android, allowing web apps to look and feel similar to native apps.\\r\\nFinally, hybrid apps are web apps wrapped inside a native device framework (e.g., Apache Cordova). These\\r\\napps have the advantages of using traditional web application development while accessing and utilizing\\r\\ndevice functions and running on multiple mobile platforms. The drawbacks are reduced speed and potential\\r\\nsecurity vulnerabilities found in the framework.\\r\\n11.1 • Modern Web Applications Architectures 575CONCEPTS IN PRACTICE\\r\\nSoftware Patterns and Frameworks\\r\\nAs discussed in Chapter 9 Software Engineering and Chapter 10 Enterprise and Solution Architectures\\r\\nManagement, architectural styles, architectural patterns, and design patterns are typically used to enforce\\r\\nthe quality attributes of software solutions. To facilitate the creation and maintenance of web applications\\r\\nand scalable transactional websites, web application frameworks and native application frameworks that\\r\\nleverage applicable patterns, such as MVC, were created and improved over the past couple of decades.\\r\\nWeb frameworks are used within web application frameworks to facilitate the use of HTML5, CSS3, and\\r\\nJavaScript and to publish responsive web pages that can be rendered by modern browsers on all modern\\r\\ntarget devices. Web application frameworks help process UI-driven requests that result in publishing or\\r\\nupdating web pages. Native application frameworks take advantage of capabilities available on specific\\r\\ntarget devices such as iPhones and Android phones. Organizations in many industries rely on web\\r\\napplications and related frameworks to conduct business daily.\\r\\nWeb 3.0 Applications\\r\\nWeb 3.0 is the next phase of the Web. It is still being realized, and similar to Web 1.0 and 2.0, it can only be\\r\\nfully understood in hindsight. The technology and uses of the Web overlap between the phases, with newer\\r\\nphases becoming preferred over their predecessor phases. If Web 1.0 was the read-only web, and Web 2.0 was\\r\\nthe participation (write) web, then Web 3.0 may be the read, write, and execute web.\\r\\nTim Berners-Lee had referred to Web 3.0 as the Semantic Web, a system of autonomous agents, which are\\r\\nsoftware programs that respond to events. That model has shifted over the years. While AI (and other\\r\\ntechnologies such as AR/VR) will likely form a part of Web 3.0 or Web x.0, the principles that govern the next\\r\\nphase are expected to be around a web that is decentralized, permissionless, and trusted.\\r\\nWeb 3.0 sees a shift from the more traditional client-server model to a peer-to-peer networking model. A peer\\x02to-peer network is one in which devices connect and can share data and processing without needing a\\r\\ncentralized server. Peers in this scheme can perform the role of a traditional client, server, or both. This shift\\r\\nwill foster a trusted, decentralized, and open web, where large companies don’t own the data, but everyone\\r\\ncollectively owns it. Technologies such as a smart contract allow a trusted model that is needed in a\\r\\ndecentralized system. Artificial intelligence and machine learning will improve information access through\\r\\nunderstanding the meaning of content available on the Web. The exemplar apps of the Web 3.0 phase will be\\r\\ndefined in the future. Still, if the previous phases of the Web are any indication, it will fundamentally change\\r\\nhow we operate in an ever-evolving technological world.\\r\\nFinally, Web 3.0 apps will run on a web that supports Web 1.0 and 2.0 apps, with the likely result being hybrid\\r\\narchitectures that are partially Web 2.0 and 3.0.\\r\\nWeb 3.0 Application Architectures\\r\\nWeb 3.0 apps are architected without a centralized server, so they are considered to be decentralized Apps\\r\\n(DApps), which are applications that execute smart contracts and run over distributed ledger technology (DLT).\\r\\nSmart contracts are programs that can be executed on a distributed ledger. Distributed ledgers use\\r\\nindependent network nodes to record, share, and synchronize transactions in their respective electronic\\r\\nledgers instead of keeping them in a centralized server. The code is visible to all parties, and trust is put into\\r\\nthe code instead of a centralized third party. Distributed ledgers chronicle transactions between accounts that\\r\\nare recorded in multiple places. Blockchain is a type of DLT.\\r\\nLet’s compare a traditional Web 2.0 application with a 3.0 DApp. In Web 2.0, if you created a website for users\\r\\nto post pictures and make comments on them, you would need functionality for authenticating users,\\r\\n576 11 • Web Applications Development\\r\\nAccess for free at openstax.orgauthorizing their actions, generating a UI for adding images, browsing images, and posting comments. To do\\r\\nthis, you would need a front-end web server and back-end processing for business logic and data storage.\\r\\nThese servers would \\nCited Pages: 585, 586, 587\\n\\nSnippet 3:\\nrameworks are important in every industry today. For example, mobile health\\napplications have become quite popular. Smartwatches can collect health-related data using various\\nsensors and mobile health applications can leverage that data to provide useful reports to users as they\\nexercise. Using a native application framework provides quicker load times, smooth animations and\\ntransitions, optimal security, and a seamless user experience, to make it easier to immediately track and\\naccess health-care data.\\nDrawbacks to using native application framework include a longer development process, increased cost,\\ncomplex maintenance and updates, platform dependency, regulatory and compliance issues, and end-user\\nbarriers.\\nThe Benefits and Drawbacks Between Native, Web, and Hybrid Mobile Application\\nDevelopment\\nNative applications have the benefits of accessing device-specific hardware and sensors (e.g., camera,\\naccelerometer), data (e.g., location, contacts), and are optimized for performance.\\nHowever, they have the drawbacks of being device-dependent and available primarily through proprietary app\\nstores (Google Play for Android and Apple’s App Store for iOS). Developers need to learn different languages\\nand libraries for the devices. However, cross-platform development is possible with frameworks (e.g., Flutter,\\nKotlin Multiplatform Mobile), allowing developers to code in a single language and run solutions on both\\nplatforms.\\nWeb apps can also run in a browser on mobile devices. They have the distinct advantage of responsiveness\\nand can run on various screen sizes—thus allo wing for a single codebase that can increase productivity and\\nreduce cost. Disadvantages to web apps on mobile devices are limited access to hardware and software\\nfeatures, lower performance than native apps, and web apps may perform differently depending on the\\nmobile browser. Traditionally, web apps didn’t look like native apps. In 2017, Google introduced Progressive\\nWeb Apps for Android, allowing web apps to look and feel similar to native apps.\\nFinally, hybrid apps are web apps wrapped inside a native device framework (e.g., Apache Cordova). These\\napps have the advantages of using traditional web application development while accessing and utilizing\\ndevice functions and running on multiple mobile platforms. The drawbacks are reduced speed and potential\\nsecurity vulnerabilities found in the framework.\\n11.1 • Modern Web Applications Architectures 575CONCEPTS IN PRACTICE\\nSoftware Patterns and Frameworks\\nAs discussed in Chapter 9 Software Engineering and Chapter 10 Enterprise and Solution Architectures\\nManagement, architectural styles, architectural patterns, and design patterns are typically used to enforce\\nthe quality attributes of software solutions. To facilitate the creation and maintenance of web applications\\nand scalable transactional websites, web application frameworks and native application frameworks that\\nleverage applicable patterns, such as MVC, were created and improved over the past couple of decades.\\nWeb frameworks are used within web application frameworks to facilitate the use of HTML5, CSS3, and\\nJavaScript and to publish responsive web pages that can be rendered by modern browsers on all modern\\ntarget devices. Web application frameworks help process UI-driven requests that result in publishing or\\nupdating web pages. Native application frameworks take advantage of capabilities available on specific\\ntarget devices such as iPhones and Android phones. Organizations in many industries rely on web\\napplications and related frameworks to conduct business daily.\\nWeb 3.0 Applications\\nWeb 3.0 is the next phase of the Web. It is still being realized, and similar to Web 1.0 and 2.0, it can only be\\nfully understood in hindsight. The technology and uses of the Web overlap between the phases, with newer\\nphases becoming preferred over their predecessor phases. If Web 1.0 was the read-only web, and Web 2.0 was\\nthe participation (write) web, then Web 3.0 may be the read, write, and execute web.\\nTim Berners-Lee had referred to Web 3.0 as the Semantic Web, a system of autonomous agents, which are\\nsoftware programs that respond to events. That model has shifted over the years. While AI (and other\\ntechnologies such as AR/VR) will likely form a part of Web 3.0 or Web x.0, the principles that govern the next\\nphase are expected to be around a web that is decentralized, permissionless, and trusted.\\nWeb 3.0 sees a shift from the more traditional client-server model to a peer-to-peer networking model. A peer-\\nto-peer network is one in which devices connect and can share data and processing without needing a\\ncentralized server. Peers in this scheme can perform the role of a traditional client, server, or both. This shift\\nwill foster a trusted, decentralized, and open web, where large companies don’t own the data, but everyone\\ncollectively owns it. Technologies such as a smart contract allow a trusted model that is needed in a\\ndecentralized system. Artificial intelligence and machine learning will improve information access through\\nunderstanding the meaning of content available on the Web. The exemplar apps of the Web 3.0 phase will be\\ndefined in the future. Still, if the previous phases of the Web are any indication, it will fundamentally change\\nhow we operate in an ever-evolving technological world.\\nFinally, Web 3.0 apps will run on a web that supports Web 1.0 and 2.0 apps, with the likely result being hybrid\\narchitectures that are partially Web 2.0 and 3.0.\\nWeb 3.0 Application Architectures\\nWeb 3.0 apps are architected without a centralized server, so they are considered to be decentralized Apps\\n(DApps), which are applications that execute smart contracts and run over distributed ledger technology (DLT).\\nSmart contracts are programs that can be executed on a distributed ledger. Distributed ledgers use\\nindependent network nodes to record, share, and synchronize transactions in their respective electronic\\nledgers instead of keeping them in a centralized server. The code is visible to all parties, and trust is put into\\nthe code instead of a centralized third party. Distributed ledgers chronicle transactions between accounts that\\nare recorded in multiple places. Blockchain is a type of DLT.\\nLet’s compare a traditional Web 2.0 application with a 3.0 DApp. In Web 2.0, if you created a website for users\\nto post pictures and make comments on them, you would need functionality for authenticating users,\\n576 11 • Web Applications Development\\nAccess for free at openstax.orgauthorizing their actions, generating a UI for adding images, browsing images, and posting comments. To do\\nthis, you would need a front-end web server and back-end processing for business logic and data storage.\\nThese servers would run in a company’s data center o\\nCited Pages: 585, 586, 587\\n\\nSnippet 4:\\nrtical Facilities as subcomponents to help classify common\\r\\nsystem architectures that may be used to assemble a complete OMA-centric architecture. It is then the\\r\\nresponsibility of the various industries to establish standard architectures that may be leveraged by\\r\\norganizations that operate in these industries. Finally, organizations benefit from being able to leverage\\r\\nfoundational, common systems and industry architectures to develop their own proprietary architectures.\\r\\nBased on the models of the various architectures that organizations may use and assuming there exists\\r\\nsolutions for them, organizations can develop their own solutions faster by reusing and customizing\\r\\nexisting solution components instead of reinventing the wheel. This is actually how the TOGAF solution\\r\\ncontinuum applies adaptive design reuse.\\r\\nResponsive Web 2.0 Business Solutions\\r\\nWorld Wide Web Consortium (W3C) is an international community that develops guidelines to ensure the\\r\\nlong-term growth and accessibility of the World Wide Web. Web 2.0 is the second generation of the World\\r\\nWide Web when we shift from static web pages to dynamic content. Web 3.0 is the third generation of the\\r\\nWorld Wide Web and represents a vision for the future of the Internet characterized by advanced technologies.\\r\\nMost modern websites rely on the Web 2.0 architectural model set forth by W3C. A sample logical application\\r\\narchitecture model is illustrated in Figure 2.26.\\r\\n2.3 • Evolving Architectures into Useable Products 75Figure 2.26 The logical application architecture of Microsoft Azure-hosted web applications allows for responsive web and mobile\\r\\nsolutions for users. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)\\r\\nIn this case, the model leverages the various components available on the Microsoft Azure Cloud. Microsoft\\r\\nAzure is a comprehensive cloud computing platform provided by Microsoft. Azure is designed to help\\r\\norganizations build, deploy, and manage applications and services through a global network of data centers.\\r\\nAzure provides streamlined development capabilities under its DevOps offering to make it very easy to develop\\r\\nand quickly deploy websites on the Azure platform using mainstream web application frameworks (e.g.,\\r\\nASP.Net, PhP, Java). DevOps is an Agile Software Engineering tools-driven approach that focuses on developing\\r\\nsoftware and deploying it into operation.\\r\\nMany of the support components required to support website implementations are readily available on\\r\\nMicrosoft Azure and other systems that provide reusable components for responsible web design. It is easy to\\r\\nevolve the model shown below into a running website. A web application framework has built-in support for\\r\\narchitectural patterns that make it easy to extend the framework and use plug-ins to implement commercial\\x02grade websites in a reasonable amount of time. They also support the use of web frameworks that make it\\r\\npossible to build a responsive web application that makes the functionality available on the desktop version of\\r\\nthe application seamlessly available on a mobile device. In addition to these capabilities, the adaptive design\\r\\nreuse approach may be used to create the custom part of the web application. More information related to the\\r\\ndevelopment of web solutions is provided in Chapter 9 Software Engineering, Chapter 10 Enterprise and\\r\\nSolution Architectures Management, and Chapter 11 Web Applications Development.\\r\\nTHINK IT THROUGH\\r\\nArchitectural Similarities\\r\\nWhat is one of the mechanisms that makes it possible to compare architectural similarities between two\\r\\nsolutions at different levels?\\r\\nNative Mobile Business Solutions\\r\\nA web application (web app) is a software application that is accessed and interacted with through a web\\r\\nbrowser over the Internet. Many web-based solutions leverage the inherent capabilities of mobile devices,\\r\\noffering web apps tailored for various types of phones in addition to responsive websites. Numerous\\r\\nframeworks exist to facilitate the development of native web apps, streamlining the process of creating\\r\\n76 2 • Computational Thinking and Design Reusability\\r\\nAccess for free at openstax.orgapplications that can run seamlessly on different mobile platforms. These frameworks often provide a unified\\r\\nand efficient approach to building cross-platform mobile applications, ensuring a consistent user experience\\r\\nacross various devices.\\r\\nIn certain frameworks and development environments, React Native UI component libraries can be leveraged\\r\\nto, port web apps to mobile devices. Examples include React Native support for Android apps using the\\r\\nAndroid Studio (Android Studio provides a comprehensive environment for developing, testing, and\\r\\ndebugging Android apps) or iPhone web app using XCode IDEs (Xcode is an integrated development\\r\\nenvironment [IDE] developed by Apple for macOS that offers a suite of tools for building software for Apple\\r\\nplatforms, including macOS, iOS, watchOS, and tvOS). Figure 2.27 illustrates the logical application architecture\\r\\nof mobile web apps that use React Native. In addition to these capabilities, the adaptive design reuse\\r\\napproach may be used to create the custom part of the native web app. More information related to the\\r\\ndevelopment of native web app solutions is provided in Chapter 9 Software Engineering, Chapter 10 Enterprise\\r\\nand Solution Architectures Management, and Chapter 11 Web Applications Development.\\r\\nFigure 2.27 The logical application architecture of React Native mobile web apps shows the back-end processes that allow both\\r\\nAndroid and IOS customers to use the same application. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)\\r\\nNative Mobile Business Examples\\r\\nNative mobile apps are designed specifically for mobile operating systems, providing optimal performance\\r\\nand a seamless user experience.\\r\\n• WhatsApp: WhatsApp is a native mobile app designed specifically for iOS and Android platforms. It directly\\r\\naccesses the hardware of the device, such as the GPS, camera, and microphone, which allows for features\\r\\nlike real-time location sharing, voice and video calls, and media sharing.\\r\\n• Instagram: Instagram is a photo- and video-sharing app. Native development helps Instagram manage\\r\\nhigh-quality media content efficiently, apply real-time filters, and smoothly handle in-app animations.\\r\\n• Uber Eats: Uber Eats is a food-delivery service that operates as a native app on mobile devices. Being\\r\\nnative allows the app to use device-specific features, such as GPS for tracking the delivery person’s\\r\\nlocation in real time.\\r\\n• Spotify: Spotify uses its native app to deliver personalized music and podcast streaming services. The app’s\\r\\nnative nature allows it to integrate closely with the device’s hardw\\nCited Pages: 85, 86, 87\\n\\nSnippet 5:\\nrtical Facilities as subcomponents to help classify common\\r\\nsystem architectures that may be used to assemble a complete OMA-centric architecture. It is then the\\r\\nresponsibility of the various industries to establish standard architectures that may be leveraged by\\r\\norganizations that operate in these industries. Finally, organizations benefit from being able to leverage\\r\\nfoundational, common systems and industry architectures to develop their own proprietary architectures.\\r\\nBased on the models of the various architectures that organizations may use and assuming there exists\\r\\nsolutions for them, organizations can develop their own solutions faster by reusing and customizing\\r\\nexisting solution components instead of reinventing the wheel. This is actually how the TOGAF solution\\r\\ncontinuum applies adaptive design reuse.\\r\\nResponsive Web 2.0 Business Solutions\\r\\nWorld Wide Web Consortium (W3C) is an international community that develops guidelines to ensure the\\r\\nlong-term growth and accessibility of the World Wide Web. Web 2.0 is the second generation of the World\\r\\nWide Web when we shift from static web pages to dynamic content. Web 3.0 is the third generation of the\\r\\nWorld Wide Web and represents a vision for the future of the Internet characterized by advanced technologies.\\r\\nMost modern websites rely on the Web 2.0 architectural model set forth by W3C. A sample logical application\\r\\narchitecture model is illustrated in Figure 2.26.\\r\\n2.3 • Evolving Architectures into Useable Products 75Figure 2.26 The logical application architecture of Microsoft Azure-hosted web applications allows for responsive web and mobile\\r\\nsolutions for users. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)\\r\\nIn this case, the model leverages the various components available on the Microsoft Azure Cloud. Microsoft\\r\\nAzure is a comprehensive cloud computing platform provided by Microsoft. Azure is designed to help\\r\\norganizations build, deploy, and manage applications and services through a global network of data centers.\\r\\nAzure provides streamlined development capabilities under its DevOps offering to make it very easy to develop\\r\\nand quickly deploy websites on the Azure platform using mainstream web application frameworks (e.g.,\\r\\nASP.Net, PhP, Java). DevOps is an Agile Software Engineering tools-driven approach that focuses on developing\\r\\nsoftware and deploying it into operation.\\r\\nMany of the support components required to support website implementations are readily available on\\r\\nMicrosoft Azure and other systems that provide reusable components for responsible web design. It is easy to\\r\\nevolve the model shown below into a running website. A web application framework has built-in support for\\r\\narchitectural patterns that make it easy to extend the framework and use plug-ins to implement commercial\\x02grade websites in a reasonable amount of time. They also support the use of web frameworks that make it\\r\\npossible to build a responsive web application that makes the functionality available on the desktop version of\\r\\nthe application seamlessly available on a mobile device. In addition to these capabilities, the adaptive design\\r\\nreuse approach may be used to create the custom part of the web application. More information related to the\\r\\ndevelopment of web solutions is provided in Chapter 9 Software Engineering, Chapter 10 Enterprise and\\r\\nSolution Architectures Management, and Chapter 11 Web Applications Development.\\r\\nTHINK IT THROUGH\\r\\nArchitectural Similarities\\r\\nWhat is one of the mechanisms that makes it possible to compare architectural similarities between two\\r\\nsolutions at different levels?\\r\\nNative Mobile Business Solutions\\r\\nA web application (web app) is a software application that is accessed and interacted with through a web\\r\\nbrowser over the Internet. Many web-based solutions leverage the inherent capabilities of mobile devices,\\r\\noffering web apps tailored for various types of phones in addition to responsive websites. Numerous\\r\\nframeworks exist to facilitate the development of native web apps, streamlining the process of creating\\r\\n76 2 • Computational Thinking and Design Reusability\\r\\nAccess for free at openstax.orgapplications that can run seamlessly on different mobile platforms. These frameworks often provide a unified\\r\\nand efficient approach to building cross-platform mobile applications, ensuring a consistent user experience\\r\\nacross various devices.\\r\\nIn certain frameworks and development environments, React Native UI component libraries can be leveraged\\r\\nto, port web apps to mobile devices. Examples include React Native support for Android apps using the\\r\\nAndroid Studio (Android Studio provides a comprehensive environment for developing, testing, and\\r\\ndebugging Android apps) or iPhone web app using XCode IDEs (Xcode is an integrated development\\r\\nenvironment [IDE] developed by Apple for macOS that offers a suite of tools for building software for Apple\\r\\nplatforms, including macOS, iOS, watchOS, and tvOS). Figure 2.27 illustrates the logical application architecture\\r\\nof mobile web apps that use React Native. In addition to these capabilities, the adaptive design reuse\\r\\napproach may be used to create the custom part of the native web app. More information related to the\\r\\ndevelopment of native web app solutions is provided in Chapter 9 Software Engineering, Chapter 10 Enterprise\\r\\nand Solution Architectures Management, and Chapter 11 Web Applications Development.\\r\\nFigure 2.27 The logical application architecture of React Native mobile web apps shows the back-end processes that allow both\\r\\nAndroid and IOS customers to use the same application. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)\\r\\nNative Mobile Business Examples\\r\\nNative mobile apps are designed specifically for mobile operating systems, providing optimal performance\\r\\nand a seamless user experience.\\r\\n• WhatsApp: WhatsApp is a native mobile app designed specifically for iOS and Android platforms. It directly\\r\\naccesses the hardware of the device, such as the GPS, camera, and microphone, which allows for features\\r\\nlike real-time location sharing, voice and video calls, and media sharing.\\r\\n• Instagram: Instagram is a photo- and video-sharing app. Native development helps Instagram manage\\r\\nhigh-quality media content efficiently, apply real-time filters, and smoothly handle in-app animations.\\r\\n• Uber Eats: Uber Eats is a food-delivery service that operates as a native app on mobile devices. Being\\r\\nnative allows the app to use device-specific features, such as GPS for tracking the delivery person’s\\r\\nlocation in real time.\\r\\n• Spotify: Spotify uses its native app to deliver personalized music and podcast streaming services. The app’s\\r\\nnative nature allows it to integrate closely with the device’s hardw\\nCited Pages: 85, 86, 87\\n\\nSnippet 6:\\nt Services, Horizontal Facilities, and Vertical Facilities as subcomponents to help classify common\\nsystem architectures that may be used to assemble a complete OMA-centric architecture. It is then the\\nresponsibility of the various industries to establish standard architectures that may be leveraged by\\norganizations that operate in these industries. Finally, organizations benefit from being able to leverage\\nfoundational, common systems and industry architectures to develop their own proprietary architectures.\\nBased on the models of the various architectures that organizations may use and assuming there exists\\nsolutions for them, organizations can develop their own solutions faster by reusing and customizing\\nexisting solution components instead of reinventing the wheel. This is actually how the TOGAF solution\\ncontinuum applies adaptive design reuse.\\nResponsive Web 2.0 Business Solutions\\nWorld Wide Web Consortium (W3C)is an international community that develops guidelines to ensure the\\nlong-term growth and accessibility of the World Wide Web. Web 2.0is the second generation of the World\\nWide Web when we shift from static web pages to dynamic content. Web 3.0is the third generation of the\\nWorld Wide Web and represents a vision for the future of the Internet characterized by advanced technologies.\\nMost modern websites rely on the Web 2.0 architectural model set forth by W3C. A sample logical application\\narchitecture model is illustrated in Figure 2.26.\\n2.3 • Evolving Architectures into Useable Products 75Figure2.26 The logical application architecture of Microsoft Azure-hosted web applications allows for responsive web and mobile\\nsolutions for users. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)\\nIn this case, the model leverages the various components available on the Microsoft Azure Cloud. Microsoft\\nAzureis a comprehensive cloud computing platform provided by Microsoft. Azure is designed to help\\norganizations build, deploy, and manage applications and services through a global network of data centers.\\nAzure provides streamlined development capabilities under its DevOps offering to make it very easy to develop\\nand quickly deploy websites on the Azure platform using mainstream web application frameworks (e.g.,\\nASP.Net, PhP, Java). DevOps is an Agile Software Engineering tools-driven approach that focuses on developing\\nsoftware and deploying it into operation.\\nMany of the support components required to support website implementations are readily available on\\nMicrosoft Azure and other systems that provide reusable components for responsible web design. It is easy to\\nevolve the model shown below into a running website. A web application frameworkhas built-in support for\\narchitectural patterns that make it easy to extend the framework and use plug-ins to implement commercial-\\ngrade websites in a reasonable amount of time. They also support the use of web frameworks that make it\\npossible to build a responsive web application that makes the functionality available on the desktop version of\\nthe application seamlessly available on a mobile device. In addition to these capabilities, the adaptive design\\nreuse approach may be used to create the custom part of the web application. More information related to the\\ndevelopment of web solutions is provided in Chapter 9 Software Engineering, Chapter 10 Enterprise and\\nSolution Architectures Management, and Chapter 11 Web Applications Development.\\nTHINK IT THROUGH\\nArchitectural Similarities\\nWhat is one of the mechanisms that makes it possible to compare architectural similarities between two\\nsolutions at different levels?\\nNative Mobile Business Solutions\\nA web application (web app)is a software application that is accessed and interacted with through a web\\nbrowser over the Internet. Many web-based solutions leverage the inherent capabilities of mobile devices,\\noffering web apps tailored for various types of phones in addition to responsive websites. Numerous\\nframeworks exist to facilitate the development of native web apps, streamlining the process of creating\\n76 2 • Computational Thinking and Design Reusability\\nAccess for free at openstax.orgapplications that can run seamlessly on different mobile platforms. These frameworks often provide a unified\\nand efficient approach to building cross-platform mobile applications, ensuring a consistent user experience\\nacross various devices.\\nIn certain frameworks and development environments, React Native UI component libraries can be leveraged\\nto, port web apps to mobile devices. Examples include React Native support for Android apps using the\\nAndroid Studio (Android Studio provides a comprehensive environment for developing, testing, and\\ndebugging Android apps) or iPhone web app using XCode IDEs (Xcode is an integrated development\\nenvironment [IDE] developed by Apple for macOS that offers a suite of tools for building software for Apple\\nplatforms, including macOS, iOS, watchOS, and tvOS). Figure 2.27 illustrates the logical application architecture\\nof mobile web apps that use React Native. In addition to these capabilities, the adaptive design reuse\\napproach may be used to create the custom part of the native web app. More information related to the\\ndevelopment of native web app solutions is provided in Chapter 9 Software Engineering, Chapter 10 Enterprise\\nand Solution Architectures Management, and Chapter 11 Web Applications Development.\\nFigure2.27 The logical application architecture of React Native mobile web apps shows the back-end processes that allow both\\nAndroid and IOS customers to use the same application. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)\\nNative Mobile Business Examples\\nNative mobile apps are designed specifically for mobile operating systems, providing optimal performance\\nand a seamless user experience.\\n• WhatsApp: WhatsApp is a native mobile app designed specifically for iOS and Android platforms. It directly\\naccesses the hardware of the device, such as the GPS, camera, and microphone, which allows for features\\nlike real-time location sharing, voice and video calls, and media sharing.\\n• Instagram: Instagram is a photo- and video-sharing app. Native development helps Instagram manage\\nhigh-quality media content efficiently, apply real-time filters, and smoothly handle in-app animations.\\n• Uber Eats: Uber Eats is a food-delivery service that operates as a native app on mobile devices. Being\\nnative allows the app to use device-specific features, such as GPS for tracking the delivery person’s\\nlocation in real time.\\n• Spotify: Spotify uses its native app to deliver personalized music and podcast streaming services. The app’s\\nnative nature allows it to integrate closely with the device’s hardware, offering features like offline\\nd\\nCited Pages: 85, 86, 87\\n\\nSnippet 7:\\nalability also makes it easier to deploy or update any part of the cloud-native application\\nwithout affecting the entire application.\\n• Portability: Cloud-native applications are vendor neutral because the containers microservices run in can\\nbe deployed anywhere, thereby avoiding vendor lock-in.\\n• Reliability and resiliency: If a failure occurs in one microservice, there is no effect on adjacent\\nmicroservices because cloud-native applications use containers. Resiliency is provided at the core of the\\narchitecture. As with any software system, failure can also occur in distributed systems and hardware.\\nTransient failures can also occur in networks. The ability of a system to recover from failures and continue\\nto function is called resiliency. The goal of resiliency is to return the application to a fully functioning state\\nfollowing a failure minimizing downtime and data loss. An application is resilient if it (1) has high\\navailability, which is the ability for an application to continue running in a healthy state without\\nsignificant downtime; and (2) supports disaster recovery, which is the ability of the application to recover\\nfrom rare but major incidents: nontransient, wide-scale failures, such as service disruption that affects an\\nentire region. Applications can be made resilient by increasing redundancy with multinode clusters,\\nmultiregion deployments, and data replication. Other strategies for implementing resiliency include\\nretries to handle transient network failures, adding more nodes to a cluster and load balance across them,\\nthrottling high-volume users, and applying circuit breakers to prevent an application from repeatedly\\ntrying an operation that is likely to fail.\\nTesting for resiliency requires testing how the end-to-end workload performs under failure conditions that\\nonly occur intermittently—for e xample, injecting failures by crashing processes, including expired\\ncertificates, making dependent services unavailable, and so on. Resiliency tools and frameworks like\\nChaos Monkey can be used for such chaos testing. For example, Netflix uses Chaos Monkey for resiliency\\ntesting to simulate failures and address them.\\n• Ease of management: Cloud-native application updates and added features are automated as they move\\nthrough a DevOps pipeline using CI/CD. This makes it easier for developers to track the microservices as\\nthey are being updated. Development teams can focus on managing specific microservices without\\nworrying about how it will interact with other microservices. This architecture allows teams to be chosen\\nto manage specific microservices based on the skill sets of their members.\\n• Visibility: Because a microservices architecture isolates services, it makes it easier for teams to learn how\\nthe microservices function together and have a better understanding of the cloud-native application as a\\nwhole.\\nBest Practices for Cloud-Native Application Development\\nBest practices for designing cloud-native applications are based on the DevOps principle of operational\\nexcellence to ensure the timely delivery of quality software. A cloud-native architecture has no unique rules,\\nand businesses will approach development differently based on the business problem they are solving and the\\nsoftware they are using. Adopting the DevOps principles to develop cloud-native applications, businesses gain\\nthree core advantages, such as higher-quality software released more rapidly, faster responsiveness to\\ncustomer needs, and improved working environment for development teams.\\nAll cloud-native application designs should consider how the application will be built, how performance is\\nmeasured, and how teams foster continuous improvement of the application’s performance, compliance\\nthrough the application life cycle at a faster pace, and higher quality. Here are the five essential best practices\\nfor cloud-native application design:\\n1. Automation: A development team should automate as much of the cloud-native application\\n12.1 • Introduction to Cloud-Native Applications 685development life cycle as possible. Automation helps reduce human errors and increase team\\nproductivity. It also allows for the consistent provisioning of cloud application environments across\\nmultiple cloud vendors. With automation, infrastructure as code (IaC) is used as a DevOps practice that\\nuses versioning and a declarative language to automate the provisioning of infrastructure resources\\nsuch as compute services, networks, and storage.\\n2. Monitoring: Teams should monitor the development environment, as well as how the application is\\nbeing used. Monitoring ensures the cloud-native application performs without issues. Teams can also\\nbolster the CI/CD pipeline with continuous monitoring of the application, logs, and supporting\\ninfrastructure. Continuous monitoring can also be used to identify productivity issues that may slow\\ndown the CI/CD pipeline.\\n3. Documentation: Many teams build cloud-native applications with limited to no visibility into what other\\nteams are doing. Teams with specific skills are likely to manage certain aspects of the cloud-native\\napplication because microservices are built with different programming languages and frameworks\\nthat team members specialize in. It is important to document the specifics of the microservices they\\nmanage, track changes, and monitor team contributions to the cloud-native application.\\n4. Incremental releases: Changes made to the cloud-native application or the underlying architecture\\nshould be incremental and reversible. With IaC, developers can track changes in a source repository.\\nUpdates should be released as often as possible. Incremental releases reduce the possibility of errors\\nand incompatibility issues.\\n5. Design for failure: Processes should be designed for the possibility of failures in a cloud environment.\\nImplementing test frameworks to simulate failures can mitigate risks. They can also be used to learn\\nfrom failures and to improve the overall functionality of the cloud-native application.\\nGLOBAL ISSUES IN TECHNOLOGY\\nLocal and International Implications of Cloud Applications\\nWhile cloud-native applications are used all over the world, specific internationalization (I18N) and\\nlocalization (L10N) requirements must be observed to facilitate the creation of applications that people can\\nuse. Because microservices are part of an application’s back end, they typically return keywords that can be\\nreplaced via a I18N/L10N system within the application front end. What is your opinion regarding whether\\nthis approach addresses all I18N/L10N requirements for cloud-native applications?\\nTools for Cloud-Native Application Development\\nSeveral tools are used for the cloud-native application development process. Together, they create a\\ndevelopment stack. The following tool\\nCited Pages: 695, 696\\n\\nSnippet 8:\\neploy or update any part of the cloud-native application\\r\\nwithout affecting the entire application.\\r\\n• Portability: Cloud-native applications are vendor neutral because the containers microservices run in can\\r\\nbe deployed anywhere, thereby avoiding vendor lock-in.\\r\\n• Reliability and resiliency: If a failure occurs in one microservice, there is no effect on adjacent\\r\\nmicroservices because cloud-native applications use containers. Resiliency is provided at the core of the\\r\\narchitecture. As with any software system, failure can also occur in distributed systems and hardware.\\r\\nTransient failures can also occur in networks. The ability of a system to recover from failures and continue\\r\\nto function is called resiliency. The goal of resiliency is to return the application to a fully functioning state\\r\\nfollowing a failure minimizing downtime and data loss. An application is resilient if it (1) has high\\r\\navailability, which is the ability for an application to continue running in a healthy state without\\r\\nsignificant downtime; and (2) supports disaster recovery, which is the ability of the application to recover\\r\\nfrom rare but major incidents: nontransient, wide-scale failures, such as service disruption that affects an\\r\\nentire region. Applications can be made resilient by increasing redundancy with multinode clusters,\\r\\nmultiregion deployments, and data replication. Other strategies for implementing resiliency include\\r\\nretries to handle transient network failures, adding more nodes to a cluster and load balance across them,\\r\\nthrottling high-volume users, and applying circuit breakers to prevent an application from repeatedly\\r\\ntrying an operation that is likely to fail.\\r\\nTesting for resiliency requires testing how the end-to-end workload performs under failure conditions that\\r\\nonly occur intermittently—for example, injecting failures by crashing processes, including expired\\r\\ncertificates, making dependent services unavailable, and so on. Resiliency tools and frameworks like\\r\\nChaos Monkey can be used for such chaos testing. For example, Netflix uses Chaos Monkey for resiliency\\r\\ntesting to simulate failures and address them.\\r\\n• Ease of management: Cloud-native application updates and added features are automated as they move\\r\\nthrough a DevOps pipeline using CI/CD. This makes it easier for developers to track the microservices as\\r\\nthey are being updated. Development teams can focus on managing specific microservices without\\r\\nworrying about how it will interact with other microservices. This architecture allows teams to be chosen\\r\\nto manage specific microservices based on the skill sets of their members.\\r\\n• Visibility: Because a microservices architecture isolates services, it makes it easier for teams to learn how\\r\\nthe microservices function together and have a better understanding of the cloud-native application as a\\r\\nwhole.\\r\\nBest Practices for Cloud-Native Application Development\\r\\nBest practices for designing cloud-native applications are based on the DevOps principle of operational\\r\\nexcellence to ensure the timely delivery of quality software. A cloud-native architecture has no unique rules,\\r\\nand businesses will approach development differently based on the business problem they are solving and the\\r\\nsoftware they are using. Adopting the DevOps principles to develop cloud-native applications, businesses gain\\r\\nthree core advantages, such as higher-quality software released more rapidly, faster responsiveness to\\r\\ncustomer needs, and improved working environment for development teams.\\r\\nAll cloud-native application designs should consider how the application will be built, how performance is\\r\\nmeasured, and how teams foster continuous improvement of the application’s performance, compliance\\r\\nthrough the application life cycle at a faster pace, and higher quality. Here are the five essential best practices\\r\\nfor cloud-native application design:\\r\\n1. Automation: A development team should automate as much of the cloud-native application\\r\\n12.1 • Introduction to Cloud-Native Applications 685development life cycle as possible. Automation helps reduce human errors and increase team\\r\\nproductivity. It also allows for the consistent provisioning of cloud application environments across\\r\\nmultiple cloud vendors. With automation, infrastructure as code (IaC) is used as a DevOps practice that\\r\\nuses versioning and a declarative language to automate the provisioning of infrastructure resources\\r\\nsuch as compute services, networks, and storage.\\r\\n2. Monitoring: Teams should monitor the development environment, as well as how the application is\\r\\nbeing used. Monitoring ensures the cloud-native application performs without issues. Teams can also\\r\\nbolster the CI/CD pipeline with continuous monitoring of the application, logs, and supporting\\r\\ninfrastructure. Continuous monitoring can also be used to identify productivity issues that may slow\\r\\ndown the CI/CD pipeline.\\r\\n3. Documentation: Many teams build cloud-native applications with limited to no visibility into what other\\r\\nteams are doing. Teams with specific skills are likely to manage certain aspects of the cloud-native\\r\\napplication because microservices are built with different programming languages and frameworks\\r\\nthat team members specialize in. It is important to document the specifics of the microservices they\\r\\nmanage, track changes, and monitor team contributions to the cloud-native application.\\r\\n4. Incremental releases: Changes made to the cloud-native application or the underlying architecture\\r\\nshould be incremental and reversible. With IaC, developers can track changes in a source repository.\\r\\nUpdates should be released as often as possible. Incremental releases reduce the possibility of errors\\r\\nand incompatibility issues.\\r\\n5. Design for failure: Processes should be designed for the possibility of failures in a cloud environment.\\r\\nImplementing test frameworks to simulate failures can mitigate risks. They can also be used to learn\\r\\nfrom failures and to improve the overall functionality of the cloud-native application.\\r\\nGLOBAL ISSUES IN TECHNOLOGY\\r\\nLocal and International Implications of Cloud Applications\\r\\nWhile cloud-native applications are used all over the world, specific internationalization (I18N) and\\r\\nlocalization (L10N) requirements must be observed to facilitate the creation of applications that people can\\r\\nuse. Because microservices are part of an application’s back end, they typically return keywords that can be\\r\\nreplaced via a I18N/L10N system within the application front end. What is your opinion regarding whether\\r\\nthis approach addresses all I18N/L10N requirements for cloud-native applications?\\r\\nTools for Cloud-Native Application Development\\r\\nSeveral tools are used for the cloud-native application development process. Together, they create a\\r\\nCited Pages: 695, 696\\n\\nSnippet 9:\\neploy or update any part of the cloud-native application\\r\\nwithout affecting the entire application.\\r\\n• Portability: Cloud-native applications are vendor neutral because the containers microservices run in can\\r\\nbe deployed anywhere, thereby avoiding vendor lock-in.\\r\\n• Reliability and resiliency: If a failure occurs in one microservice, there is no effect on adjacent\\r\\nmicroservices because cloud-native applications use containers. Resiliency is provided at the core of the\\r\\narchitecture. As with any software system, failure can also occur in distributed systems and hardware.\\r\\nTransient failures can also occur in networks. The ability of a system to recover from failures and continue\\r\\nto function is called resiliency. The goal of resiliency is to return the application to a fully functioning state\\r\\nfollowing a failure minimizing downtime and data loss. An application is resilient if it (1) has high\\r\\navailability, which is the ability for an application to continue running in a healthy state without\\r\\nsignificant downtime; and (2) supports disaster recovery, which is the ability of the application to recover\\r\\nfrom rare but major incidents: nontransient, wide-scale failures, such as service disruption that affects an\\r\\nentire region. Applications can be made resilient by increasing redundancy with multinode clusters,\\r\\nmultiregion deployments, and data replication. Other strategies for implementing resiliency include\\r\\nretries to handle transient network failures, adding more nodes to a cluster and load balance across them,\\r\\nthrottling high-volume users, and applying circuit breakers to prevent an application from repeatedly\\r\\ntrying an operation that is likely to fail.\\r\\nTesting for resiliency requires testing how the end-to-end workload performs under failure conditions that\\r\\nonly occur intermittently—for example, injecting failures by crashing processes, including expired\\r\\ncertificates, making dependent services unavailable, and so on. Resiliency tools and frameworks like\\r\\nChaos Monkey can be used for such chaos testing. For example, Netflix uses Chaos Monkey for resiliency\\r\\ntesting to simulate failures and address them.\\r\\n• Ease of management: Cloud-native application updates and added features are automated as they move\\r\\nthrough a DevOps pipeline using CI/CD. This makes it easier for developers to track the microservices as\\r\\nthey are being updated. Development teams can focus on managing specific microservices without\\r\\nworrying about how it will interact with other microservices. This architecture allows teams to be chosen\\r\\nto manage specific microservices based on the skill sets of their members.\\r\\n• Visibility: Because a microservices architecture isolates services, it makes it easier for teams to learn how\\r\\nthe microservices function together and have a better understanding of the cloud-native application as a\\r\\nwhole.\\r\\nBest Practices for Cloud-Native Application Development\\r\\nBest practices for designing cloud-native applications are based on the DevOps principle of operational\\r\\nexcellence to ensure the timely delivery of quality software. A cloud-native architecture has no unique rules,\\r\\nand businesses will approach development differently based on the business problem they are solving and the\\r\\nsoftware they are using. Adopting the DevOps principles to develop cloud-native applications, businesses gain\\r\\nthree core advantages, such as higher-quality software released more rapidly, faster responsiveness to\\r\\ncustomer needs, and improved working environment for development teams.\\r\\nAll cloud-native application designs should consider how the application will be built, how performance is\\r\\nmeasured, and how teams foster continuous improvement of the application’s performance, compliance\\r\\nthrough the application life cycle at a faster pace, and higher quality. Here are the five essential best practices\\r\\nfor cloud-native application design:\\r\\n1. Automation: A development team should automate as much of the cloud-native application\\r\\n12.1 • Introduction to Cloud-Native Applications 685development life cycle as possible. Automation helps reduce human errors and increase team\\r\\nproductivity. It also allows for the consistent provisioning of cloud application environments across\\r\\nmultiple cloud vendors. With automation, infrastructure as code (IaC) is used as a DevOps practice that\\r\\nuses versioning and a declarative language to automate the provisioning of infrastructure resources\\r\\nsuch as compute services, networks, and storage.\\r\\n2. Monitoring: Teams should monitor the development environment, as well as how the application is\\r\\nbeing used. Monitoring ensures the cloud-native application performs without issues. Teams can also\\r\\nbolster the CI/CD pipeline with continuous monitoring of the application, logs, and supporting\\r\\ninfrastructure. Continuous monitoring can also be used to identify productivity issues that may slow\\r\\ndown the CI/CD pipeline.\\r\\n3. Documentation: Many teams build cloud-native applications with limited to no visibility into what other\\r\\nteams are doing. Teams with specific skills are likely to manage certain aspects of the cloud-native\\r\\napplication because microservices are built with different programming languages and frameworks\\r\\nthat team members specialize in. It is important to document the specifics of the microservices they\\r\\nmanage, track changes, and monitor team contributions to the cloud-native application.\\r\\n4. Incremental releases: Changes made to the cloud-native application or the underlying architecture\\r\\nshould be incremental and reversible. With IaC, developers can track changes in a source repository.\\r\\nUpdates should be released as often as possible. Incremental releases reduce the possibility of errors\\r\\nand incompatibility issues.\\r\\n5. Design for failure: Processes should be designed for the possibility of failures in a cloud environment.\\r\\nImplementing test frameworks to simulate failures can mitigate risks. They can also be used to learn\\r\\nfrom failures and to improve the overall functionality of the cloud-native application.\\r\\nGLOBAL ISSUES IN TECHNOLOGY\\r\\nLocal and International Implications of Cloud Applications\\r\\nWhile cloud-native applications are used all over the world, specific internationalization (I18N) and\\r\\nlocalization (L10N) requirements must be observed to facilitate the creation of applications that people can\\r\\nuse. Because microservices are part of an application’s back end, they typically return keywords that can be\\r\\nreplaced via a I18N/L10N system within the application front end. What is your opinion regarding whether\\r\\nthis approach addresses all I18N/L10N requirements for cloud-native applications?\\r\\nTools for Cloud-Native Application Development\\r\\nSeveral tools are used for the cloud-native application development process. Together, they create a\\r\\nCited Pages: 695, 696\\n\\nSnippet 10:\\nbles computations. The processor can\\r\\nbe regarded as the computer’s “brain,” as it follows instructions from algorithms and processes data. The\\r\\nmemory is a means of addressing information in a computer by storing it in consistent locations, while the\\r\\nnetwork refers to the various technological devices that are connected and share information. The hardware\\r\\nand physical components of a computer that permanently house a computer’s data are called storage.\\r\\nOne way to understand computers is from a hardware perspective: computers leverage digital electronics and\\r\\nthe physics of materials used to develop transistors. For example, many of today’s computers rely on the\\r\\nphysical properties of a brittle, crystalline metalloid called silicon, which makes it suitable for representing\\r\\ninformation. The batteries that power many of today’s smartphones and mobile devices rely on lithium, a soft,\\r\\nsilvery metal mostly harvested from minerals in Australia, Zimbabwe, and Brazil, as well as from continental\\r\\nbrine deposits in Chile, Argentina, and Bolivia. Computer engineers combine these substances to build\\r\\ncircuitry and information pathways at the microscopic scale to form the physical basis for modern computers.\\r\\nHowever, the physical basis of computers was not always silicon. The Electronic Numerical Integrator and\\r\\nComputer (ENIAC) was completed in 1945, making it one of the earliest digital computers. The ENIAC operated\\r\\non different physical principles. Instead of silicon, the ENIAC used the technology of a vacuum tube, a physical\\r\\ndevice like a light bulb that was used as memory in early digital computers. When the “light” in the vacuum\\r\\ntube is off, the vacuum tube represents the number 0. When the “light” is on, the vacuum tube represents the\\r\\nnumber 1. When thousands of vacuum tubes are combined in a logical way, we suddenly have memory. The\\r\\nENIAC is notable in computer history because it was the first general-purpose computer, meaning that it could\\r\\nrun not just a single program but rather any program specified by a programmer. The ENIAC was often run\\r\\nand programmed by women programmers (Figure 1.4). Despite its age and differences in hardware properties,\\r\\nit shares a fundamental and surprising similarity with modern computers. Anything that can be computed on\\r\\n1.1 • Computer Science 13today’s computers can also be computed by the ENIAC given the right circumstances—just trillions of times\\r\\nmore slowly.\\r\\nFigure 1.4 This image depicts women programmers holding boards used in computers such as the ENIAC, many of which were\\r\\ndesigned expressly for ballistics and ordinance guidance research. Today, these room-size computers can be reproduced at a literally\\r\\nmicroscopic scale—basically invisible to the human eye. (credit: modification of \"Women holding parts of the first four Army\\r\\ncomputers\" by U.S. Army/Wikimedia Commons, Public Domain)\\r\\nHow is this possible? The algorithmic principles that determine how results are computed makes up software.\\r\\nAlmost all computers, from the ENIAC to today’s computers, are considered Turing-complete (or\\r\\nComputationally Universal, as opposed to specialized computing devices such as scientific calculators) because\\r\\nthey share the same fundamental model for computing results and every computer has the ability to run any\\r\\nalgorithm. Alan Mathison Turing was an English mathematician who was highly influential in the development\\r\\nof theoretical computer science, which focuses on the mathematical processes behind software, and provided\\r\\na formalization of the concepts of algorithm and computation with the Turing machine. A Turing-complete\\r\\ncomputer stores data in memory (either using vacuum tubes or silicon) and manipulates that data according\\r\\nto a computer program, which is an algorithm that can be run on a computer. These programs are\\r\\nrepresented using symbols and instructions written in a programming language consisting of symbols and\\r\\ninstructions that can be interpreted by the computer. Programs are also stored in memory, which allows\\r\\nprogrammers to modify and improve programs by changing the instructions.\\r\\nWhile both hardware and software are important to the practical operation of computers, computer science’s\\r\\nhistorical roots in mathematics also emphasize a third perspective. Whereas software focuses on the program\\r\\ndetails for solving problems with computers, theoretical computer science focuses on the mathematical\\r\\nprocesses behind software. The idea of Turing-completeness is a foundational concept in theoretical computer\\r\\nscience, which considers how computers in general—not just the ENIAC or today’s computers, but even\\r\\ntomorrow’s computers that we haven’t yet invented—can solve problems. This theoretical perspective expands\\r\\ncomputer science knowledge by contributing ideas about (1) whether a problem can be computed by a Turing\\x02complete computer at all, (2) how that problem might be computed using an algorithm, and (3) how quickly or\\r\\nefficiently a computer can run such an algorithm. The answers to these questions suggest the limits of what\\r\\nwe can achieve with computers from a technical perspective: Using mathematical ideas, is it possible to use a\\r\\ncomputer to compute all problems? If the answer to a problem is yes, how much of a computing resource is\\r\\nneeded to get the answer?\\r\\nClearly both humans and computers have their strengths and limitations. An example of a problem that\\r\\nhumans can solve but computers struggle with is interpreting subtle emotions or making moral judgments in\\r\\ncomplex social situations. While computers can process data and recognize patterns, they cannot fully\\r\\nunderstand the nuances of human emotions or ethics, which often involve context, empathy, and experience.\\r\\n14 1 • Introduction to Computer Science\\r\\nAccess for free at openstax.orgOn the flip side, there are tasks that neither computers nor humans can perform, such as accurately predicting\\r\\nchaotic systems like long-term weather patterns. Despite advancements in artificial intelligence (AI),\\r\\ncomputer functions that perform tasks, such as visual perception and decision-making processes that usually\\r\\nare performed by human intelligence, these problems remain beyond our collective reach due to the inherent\\r\\nunpredictability and complexity of certain natural systems.\\r\\nTheoretical computer science is often emphasized in undergraduate computer science programs because\\r\\nacademic computer science emerged from mathematics, often to the detriment of perspectives that center on\\r\\nthe social and technical values embodied by applications of computer technology. These perspectives,\\r\\nhowever, are gradually changing. Just as the design of ARPANET shaped the design of the Internet, computer\\r\\nscientists are also learning that the physical a\\nCited Pages: 23, 24, 25\\n\\nSnippet 11:\\nbles computations. The processor can\\r\\nbe regarded as the computer’s “brain,” as it follows instructions from algorithms and processes data. The\\r\\nmemory is a means of addressing information in a computer by storing it in consistent locations, while the\\r\\nnetwork refers to the various technological devices that are connected and share information. The hardware\\r\\nand physical components of a computer that permanently house a computer’s data are called storage.\\r\\nOne way to understand computers is from a hardware perspective: computers leverage digital electronics and\\r\\nthe physics of materials used to develop transistors. For example, many of today’s computers rely on the\\r\\nphysical properties of a brittle, crystalline metalloid called silicon, which makes it suitable for representing\\r\\ninformation. The batteries that power many of today’s smartphones and mobile devices rely on lithium, a soft,\\r\\nsilvery metal mostly harvested from minerals in Australia, Zimbabwe, and Brazil, as well as from continental\\r\\nbrine deposits in Chile, Argentina, and Bolivia. Computer engineers combine these substances to build\\r\\ncircuitry and information pathways at the microscopic scale to form the physical basis for modern computers.\\r\\nHowever, the physical basis of computers was not always silicon. The Electronic Numerical Integrator and\\r\\nComputer (ENIAC) was completed in 1945, making it one of the earliest digital computers. The ENIAC operated\\r\\non different physical principles. Instead of silicon, the ENIAC used the technology of a vacuum tube, a physical\\r\\ndevice like a light bulb that was used as memory in early digital computers. When the “light” in the vacuum\\r\\ntube is off, the vacuum tube represents the number 0. When the “light” is on, the vacuum tube represents the\\r\\nnumber 1. When thousands of vacuum tubes are combined in a logical way, we suddenly have memory. The\\r\\nENIAC is notable in computer history because it was the first general-purpose computer, meaning that it could\\r\\nrun not just a single program but rather any program specified by a programmer. The ENIAC was often run\\r\\nand programmed by women programmers (Figure 1.4). Despite its age and differences in hardware properties,\\r\\nit shares a fundamental and surprising similarity with modern computers. Anything that can be computed on\\r\\n1.1 • Computer Science 13today’s computers can also be computed by the ENIAC given the right circumstances—just trillions of times\\r\\nmore slowly.\\r\\nFigure 1.4 This image depicts women programmers holding boards used in computers such as the ENIAC, many of which were\\r\\ndesigned expressly for ballistics and ordinance guidance research. Today, these room-size computers can be reproduced at a literally\\r\\nmicroscopic scale—basically invisible to the human eye. (credit: modification of \"Women holding parts of the first four Army\\r\\ncomputers\" by U.S. Army/Wikimedia Commons, Public Domain)\\r\\nHow is this possible? The algorithmic principles that determine how results are computed makes up software.\\r\\nAlmost all computers, from the ENIAC to today’s computers, are considered Turing-complete (or\\r\\nComputationally Universal, as opposed to specialized computing devices such as scientific calculators) because\\r\\nthey share the same fundamental model for computing results and every computer has the ability to run any\\r\\nalgorithm. Alan Mathison Turing was an English mathematician who was highly influential in the development\\r\\nof theoretical computer science, which focuses on the mathematical processes behind software, and provided\\r\\na formalization of the concepts of algorithm and computation with the Turing machine. A Turing-complete\\r\\ncomputer stores data in memory (either using vacuum tubes or silicon) and manipulates that data according\\r\\nto a computer program, which is an algorithm that can be run on a computer. These programs are\\r\\nrepresented using symbols and instructions written in a programming language consisting of symbols and\\r\\ninstructions that can be interpreted by the computer. Programs are also stored in memory, which allows\\r\\nprogrammers to modify and improve programs by changing the instructions.\\r\\nWhile both hardware and software are important to the practical operation of computers, computer science’s\\r\\nhistorical roots in mathematics also emphasize a third perspective. Whereas software focuses on the program\\r\\ndetails for solving problems with computers, theoretical computer science focuses on the mathematical\\r\\nprocesses behind software. The idea of Turing-completeness is a foundational concept in theoretical computer\\r\\nscience, which considers how computers in general—not just the ENIAC or today’s computers, but even\\r\\ntomorrow’s computers that we haven’t yet invented—can solve problems. This theoretical perspective expands\\r\\ncomputer science knowledge by contributing ideas about (1) whether a problem can be computed by a Turing\\x02complete computer at all, (2) how that problem might be computed using an algorithm, and (3) how quickly or\\r\\nefficiently a computer can run such an algorithm. The answers to these questions suggest the limits of what\\r\\nwe can achieve with computers from a technical perspective: Using mathematical ideas, is it possible to use a\\r\\ncomputer to compute all problems? If the answer to a problem is yes, how much of a computing resource is\\r\\nneeded to get the answer?\\r\\nClearly both humans and computers have their strengths and limitations. An example of a problem that\\r\\nhumans can solve but computers struggle with is interpreting subtle emotions or making moral judgments in\\r\\ncomplex social situations. While computers can process data and recognize patterns, they cannot fully\\r\\nunderstand the nuances of human emotions or ethics, which often involve context, empathy, and experience.\\r\\n14 1 • Introduction to Computer Science\\r\\nAccess for free at openstax.orgOn the flip side, there are tasks that neither computers nor humans can perform, such as accurately predicting\\r\\nchaotic systems like long-term weather patterns. Despite advancements in artificial intelligence (AI),\\r\\ncomputer functions that perform tasks, such as visual perception and decision-making processes that usually\\r\\nare performed by human intelligence, these problems remain beyond our collective reach due to the inherent\\r\\nunpredictability and complexity of certain natural systems.\\r\\nTheoretical computer science is often emphasized in undergraduate computer science programs because\\r\\nacademic computer science emerged from mathematics, often to the detriment of perspectives that center on\\r\\nthe social and technical values embodied by applications of computer technology. These perspectives,\\r\\nhowever, are gradually changing. Just as the design of ARPANET shaped the design of the Internet, computer\\r\\nscientists are also learning that the physical a\\nCited Pages: 23, 24, 25\\n\\nSnippet 12:\\n—is the computer component that enables computations. The processorcan\\nbe regarded as the computer’s “brain,” as it follows instructions from algorithms and processes data. The\\nmemoryis a means of addressing information in a computer by storing it in consistent locations, while the\\nnetworkrefers to the various technological devices that are connected and share information. The hardware\\nand physical components of a computer that permanently house a computer’s data are called storage.\\nOne way to understand computers is from a hardware perspective: computers leverage digital electronics and\\nthe physics of materials used to develop transistors. For example, many of today’s computers rely on the\\nphysical properties of a brittle, crystalline metalloid called silicon, which makes it suitable for representing\\ninformation. The batteries that power many of today’s smartphones and mobile devices rely on lithium, a soft,\\nsilvery metal mostly harvested from minerals in Australia, Zimbabwe, and Brazil, as well as from continental\\nbrine deposits in Chile, Argentina, and Bolivia. Computer engineers combine these substances to build\\ncircuitry and information pathways at the microscopic scale to form the physical basis for modern computers.\\nHowever, the physical basis of computers was not always silicon. The Electronic Numerical Integrator and\\nComputer (ENIAC) was completed in 1945, making it one of the earliest digital computers. The ENIAC operated\\non different physical principles. Instead of silicon, the ENIAC used the technology of a vacuum tube, a physical\\ndevice like a light bulb that was used as memory in early digital computers. When the “light” in the vacuum\\ntube is off, the vacuum tube represents the number 0. When the “light” is on, the vacuum tube represents the\\nnumber 1. When thousands of vacuum tubes are combined in a logical way, we suddenly have memory. The\\nENIAC is notable in computer history because it was the first general-purpose computer, meaning that it could\\nrun not just a single program but rather any program specified by a programmer. The ENIAC was often run\\nand programmed by women programmers (Figure 1.4). Despite its age and differences in hardware properties,\\nit shares a fundamental and surprising similarity with modern computers. Anything that can be computed on\\n1.1 • Computer Science 13today’s computers can also be computed by the ENIAC given the right circumstances—just trillions of times\\nmore slowly.\\nFigure1.4 This image depicts women programmers holding boards used in computers such as the ENIAC, many of which were\\ndesigned expressly for ballistics and ordinance guidance research. Today, these room-size computers can be reproduced at a literally\\nmicroscopic scale—basically invisible to the human e ye. (credit: modification of \"Women holding parts of the first four Army\\ncomputers\" by U.S. Army/Wikimedia Commons, Public Domain)\\nHow is this possible? The algorithmic principles that determine how results are computed makes up software.\\nAlmost all computers, from the ENIAC to today’s computers, are considered Turing-complete(or\\nComputationally Universal, as opposed to specialized computing devices such as scientific calculators) because\\nthey share the same fundamental model for computing results and every computer has the ability to run any\\nalgorithm. Alan Mathison Turing was an English mathematician who was highly influential in the development\\nof theoretical computer science, which focuses on the mathematical processes behind software, and provided\\na formalization of the concepts of algorithm and computation with the Turing machine. A Turing-complete\\ncomputer stores data in memory (either using vacuum tubes or silicon) and manipulates that data according\\nto a computer program, which is an algorithm that can be run on a computer. These programs are\\nrepresented using symbols and instructions written in a programming languageconsisting of symbols and\\ninstructions that can be interpreted by the computer. Programs are also stored in memory, which allows\\nprogrammers to modify and improve programs by changing the instructions.\\nWhile both hardware and software are important to the practical operation of computers, computer science’s\\nhistorical roots in mathematics also emphasize a third perspective. Whereas software focuses on the program\\ndetails for solving problems with computers, theoretical computer science focuses on the mathematical\\nprocesses behind software. The idea of Turing-completeness is a foundational concept in theoretical computer\\nscience, which considers how computers in general—not just the ENIAC or today’s computers, but even\\ntomorrow’s computers that we haven’t yet invented—can solve pr oblems. This theoretical perspective expands\\ncomputer science knowledge by contributing ideas about (1) whether a problem can be computed by a Turing-\\ncomplete computer at all, (2) how that problem might be computed using an algorithm, and (3) how quickly or\\nefficiently a computer can run such an algorithm. The answers to these questions suggest the limits of what\\nwe can achieve with computers from a technical perspective: Using mathematical ideas, is it possible to use a\\ncomputer to compute all problems? If the answer to a problem is yes, how much of a computing resource is\\nneeded to get the answer?\\nClearly both humans and computers have their strengths and limitations. An example of a problem that\\nhumans can solve but computers struggle with is interpreting subtle emotions or making moral judgments in\\ncomplex social situations. While computers can process data and recognize patterns, they cannot fully\\nunderstand the nuances of human emotions or ethics, which often involve context, empathy, and experience.\\n14 1 • Introduction to Computer Science\\nAccess for free at openstax.orgOn the flip side, there are tasks that neither computers nor humans can perform, such as accurately predicting\\nchaotic systems like long-term weather patterns. Despite advancements in artificial intelligence (AI),\\ncomputer functions that perform tasks, such as visual perception and decision-making processes that usually\\nare performed by human intelligence, these problems remain beyond our collective reach due to the inherent\\nunpredictability and complexity of certain natural systems.\\nTheoretical computer science is often emphasized in undergraduate computer science programs because\\nacademic computer science emerged from mathematics, often to the detriment of perspectives that center on\\nthe social and technical values embodied by applications of computer technology. These perspectives,\\nhowever, are gradually changing. Just as the design of ARPANET shaped the design of the Internet, computer\\nscientists are also learning that the physical aspects of computer hardware dete\\nCited Pages: 23, 24, 25\\n\\nSnippet 13:\\nce to\\r\\nget and set data via HTTP requests. Django serves as the back end.\\r\\n• To build the Todo application using Bootstrap with React and Django, you need Python v3.9.4, PIP v21.3.1,\\r\\nDjango v4.0.1, Django REST Framework v3.13.1, Bootstrap v4.5.0, Django-cors-headers v3.11.0, React\\r\\nv17.0.2, and Axios v0.21.0.\\r\\n• The React application uses Axios to fetch data by making requests to a given endpoint.\\r\\n• A proxy to the Django application helps tunnel API requests from the React application to\\r\\nhttp://localhost:8000, where the Django application will receive and handle the requests.\\r\\n11.5 Sample Native WAD with React Native and Node or Django\\r\\n• A Todo application for mobile devices can be developed using React Native and Node.\\r\\n• React Native is an open-source JavaScript framework used to build user interfaces and native applications\\r\\nfor mobile devices.\\r\\n• To build a Todo application for mobile devices, React Native serves as the front end handling the user\\r\\ninterface and getting and setting data via HTTP requests. Node serves as the back end that makes use of\\r\\nthe API built using the Django REST Framework in 11.2 Sample Responsive WAD with Bootstrap and\\r\\nDjango.\\r\\n• Building the Todo mobile application using React Native and Node requires React Native v0.67, Node\\r\\nv14.17.5, ExpressJS v4.17.2, MongooseJS v6.1.9, and Axios v0.21.0.\\r\\n11.6 Sample Ethereum Blockchain Web 2.0/Web 3.0 Application\\r\\n• A simple Todo application can be created using React with Web 3.0 powered by Ethereum smart contracts\\r\\non the blockchain.\\r\\n• The Ethereum blockchain creates a secure peer-to-peer network through the use of smart contracts, which\\r\\nare secure digital agreements that enable users to transact directly with each other via the Web.\\r\\n• Building the Todo Ethereum blockchain Web 3.0 application requires React v17.0.2, Bootstrap v4.5.0, Node\\r\\nv14.17.5, Web 3.js v1.2.2, Truffle v5.0.2, Solidity v0.8.11, and Ganache.\\r\\n• The Truffle Framework, which is a suite of tools popular to develop smart contracts, can be used to\\r\\ndevelop the Ethereum smart contract.\\r\\n• The Truffle Framework can be implemented using Solidity, which is a high-level, object-oriented language\\r\\nthat is focused on the implementation of smart contracts.\\r\\nReview Questions\\r\\n1. What is MVC?\\r\\na. the primary design pattern used for SPA applications\\r\\n658 11 • Chapter Review\\r\\nAccess for free at openstax.orgb. a software architecture pattern that separates a system’s presentation, business logic, and data\\r\\nc. a software pattern for loose coupling and high cohesion\\r\\nd. stands for Multi-Vector Chain, a principal technology used in Web 3.0 blockchain applications\\r\\n2. What is a web application framework?\\r\\na. software designed to aid in developing web applications\\r\\nb. software that restricts the boundaries and edges of the network for the application\\r\\nc. software that provides cybersecurity for web applications\\r\\nd. software that increases the performance of a web application when networking traffic is heavy\\r\\n3. What is a native application framework?\\r\\na. software designed to support development and execution targeted toward a specific platform (e.g.,\\r\\nAndroid, iOS)\\r\\nb. program for writing assembly language for a given device\\r\\nc. software tools created by a company that also creates the targeted device\\r\\nd. software designed for responsive Web 2.0 SPA applications\\r\\n4. List examples of web and native application frameworks.\\r\\n5. Why is it difficult to implement server-side rendering using MVC?\\r\\n6. What is a responsive web application?\\r\\na. a web application that runs very quickly\\r\\nb. the web application runs as an SPA\\r\\nc. a web application that changes the look and feel based on the user’s credentials\\r\\nd. a web application that is effective regardless of a user’s device constraints, such as screen size or\\r\\norientation\\r\\n7. What is jQuery?\\r\\na. a web application framework like Angular\\r\\nb. the official name for JavaScript\\r\\nc. an open-source JavaScript library used for browser-based functionality\\r\\nd. a Java-based implementation for server-side rendering\\r\\n8. What is the difference between the first and current generations of web frameworks?\\r\\na. The names were changed; however, they have no differences.\\r\\nb. Current web frameworks require blockchain, while previous generations did not.\\r\\nc. First-generation web frameworks only used HTML and CSS, while current versions use JavaScript.\\r\\nd. Current generation web frameworks adhere to updated web standards and resolve issues with the\\r\\ninitial implementations.\\r\\n9. What are the differences between Web 2.0 and Web 3.0 applications?\\r\\n10. What is Bootstrap?\\r\\na. a Python-based web application development framework\\r\\nb. a tool to control response outputs and convert complex data into content, such as JSON\\r\\nc. an open-source, responsive web application framework\\r\\nd. a high-level directory used to contain the directories and files necessary to run a Django web\\r\\napplication\\r\\n11. Using Bootstrap and Django, what should you do to define the Todo model?\\r\\n11 • Chapter Review 659a. create serializers\\r\\nb. use the default Django admin interface to perform CRUD operations on the database\\r\\nc. enter category names and click the Post button\\r\\nd. install Bootstrap\\r\\n12. Why is the View function important?\\r\\na. The View function enables users to create user interfaces.\\r\\nb. The View function creates a Django project, which is needed to contain directories and files.\\r\\nc. The View function is required to generate the todo/ directory.\\r\\nd. The View function is needed to interact with the database to both create and delete todo items.\\r\\n13. When a Mongoose schema is defined for the todos model, what happens?\\r\\na. A todos collection is created in the MongoDB database.\\r\\nb. The REST APIs are built in the MongoDB database.\\r\\nc. A todos collection is created in the Express web server.\\r\\nd. The REST APIs are created in the Express web server.\\r\\n14. What does the controller do?\\r\\na. The controller contains code that configures the MongoDB database and Mongoose.\\r\\nb. The controller contains code that builds the REST APIs.\\r\\nc. The controller contains code that creates the React components.\\r\\nd. The controller contains code that calls the Mongoose CRUD functions to interact with the\\r\\nMongoDB database.\\r\\n15. What is Postman?\\r\\na. the port that runs the Express web server\\r\\nb. an API platform testing tool\\r\\nc. the database connection URL to the Mongo DB database\\r\\nd. the connection that allows the CRUD functions to interact with the Express web server\\r\\n16. What is the purpose of Axios?\\r\\na. Axios runs the Express web server.\\r\\nb. Axios is used by the Node application to fetch data by making requests to a given endpoint.\\r\\nc. Axios runs the MongoDB database.\\r\\nd. Axios is used by the React application to fetch data by making requests to a given endpoint.\\r\\n17\\nCited Pages: 668, 669, 670\\n\\nSnippet 14:\\nce to\\r\\nget and set data via HTTP requests. Django serves as the back end.\\r\\n• To build the Todo application using Bootstrap with React and Django, you need Python v3.9.4, PIP v21.3.1,\\r\\nDjango v4.0.1, Django REST Framework v3.13.1, Bootstrap v4.5.0, Django-cors-headers v3.11.0, React\\r\\nv17.0.2, and Axios v0.21.0.\\r\\n• The React application uses Axios to fetch data by making requests to a given endpoint.\\r\\n• A proxy to the Django application helps tunnel API requests from the React application to\\r\\nhttp://localhost:8000, where the Django application will receive and handle the requests.\\r\\n11.5 Sample Native WAD with React Native and Node or Django\\r\\n• A Todo application for mobile devices can be developed using React Native and Node.\\r\\n• React Native is an open-source JavaScript framework used to build user interfaces and native applications\\r\\nfor mobile devices.\\r\\n• To build a Todo application for mobile devices, React Native serves as the front end handling the user\\r\\ninterface and getting and setting data via HTTP requests. Node serves as the back end that makes use of\\r\\nthe API built using the Django REST Framework in 11.2 Sample Responsive WAD with Bootstrap and\\r\\nDjango.\\r\\n• Building the Todo mobile application using React Native and Node requires React Native v0.67, Node\\r\\nv14.17.5, ExpressJS v4.17.2, MongooseJS v6.1.9, and Axios v0.21.0.\\r\\n11.6 Sample Ethereum Blockchain Web 2.0/Web 3.0 Application\\r\\n• A simple Todo application can be created using React with Web 3.0 powered by Ethereum smart contracts\\r\\non the blockchain.\\r\\n• The Ethereum blockchain creates a secure peer-to-peer network through the use of smart contracts, which\\r\\nare secure digital agreements that enable users to transact directly with each other via the Web.\\r\\n• Building the Todo Ethereum blockchain Web 3.0 application requires React v17.0.2, Bootstrap v4.5.0, Node\\r\\nv14.17.5, Web 3.js v1.2.2, Truffle v5.0.2, Solidity v0.8.11, and Ganache.\\r\\n• The Truffle Framework, which is a suite of tools popular to develop smart contracts, can be used to\\r\\ndevelop the Ethereum smart contract.\\r\\n• The Truffle Framework can be implemented using Solidity, which is a high-level, object-oriented language\\r\\nthat is focused on the implementation of smart contracts.\\r\\nReview Questions\\r\\n1. What is MVC?\\r\\na. the primary design pattern used for SPA applications\\r\\n658 11 • Chapter Review\\r\\nAccess for free at openstax.orgb. a software architecture pattern that separates a system’s presentation, business logic, and data\\r\\nc. a software pattern for loose coupling and high cohesion\\r\\nd. stands for Multi-Vector Chain, a principal technology used in Web 3.0 blockchain applications\\r\\n2. What is a web application framework?\\r\\na. software designed to aid in developing web applications\\r\\nb. software that restricts the boundaries and edges of the network for the application\\r\\nc. software that provides cybersecurity for web applications\\r\\nd. software that increases the performance of a web application when networking traffic is heavy\\r\\n3. What is a native application framework?\\r\\na. software designed to support development and execution targeted toward a specific platform (e.g.,\\r\\nAndroid, iOS)\\r\\nb. program for writing assembly language for a given device\\r\\nc. software tools created by a company that also creates the targeted device\\r\\nd. software designed for responsive Web 2.0 SPA applications\\r\\n4. List examples of web and native application frameworks.\\r\\n5. Why is it difficult to implement server-side rendering using MVC?\\r\\n6. What is a responsive web application?\\r\\na. a web application that runs very quickly\\r\\nb. the web application runs as an SPA\\r\\nc. a web application that changes the look and feel based on the user’s credentials\\r\\nd. a web application that is effective regardless of a user’s device constraints, such as screen size or\\r\\norientation\\r\\n7. What is jQuery?\\r\\na. a web application framework like Angular\\r\\nb. the official name for JavaScript\\r\\nc. an open-source JavaScript library used for browser-based functionality\\r\\nd. a Java-based implementation for server-side rendering\\r\\n8. What is the difference between the first and current generations of web frameworks?\\r\\na. The names were changed; however, they have no differences.\\r\\nb. Current web frameworks require blockchain, while previous generations did not.\\r\\nc. First-generation web frameworks only used HTML and CSS, while current versions use JavaScript.\\r\\nd. Current generation web frameworks adhere to updated web standards and resolve issues with the\\r\\ninitial implementations.\\r\\n9. What are the differences between Web 2.0 and Web 3.0 applications?\\r\\n10. What is Bootstrap?\\r\\na. a Python-based web application development framework\\r\\nb. a tool to control response outputs and convert complex data into content, such as JSON\\r\\nc. an open-source, responsive web application framework\\r\\nd. a high-level directory used to contain the directories and files necessary to run a Django web\\r\\napplication\\r\\n11. Using Bootstrap and Django, what should you do to define the Todo model?\\r\\n11 • Chapter Review 659a. create serializers\\r\\nb. use the default Django admin interface to perform CRUD operations on the database\\r\\nc. enter category names and click the Post button\\r\\nd. install Bootstrap\\r\\n12. Why is the View function important?\\r\\na. The View function enables users to create user interfaces.\\r\\nb. The View function creates a Django project, which is needed to contain directories and files.\\r\\nc. The View function is required to generate the todo/ directory.\\r\\nd. The View function is needed to interact with the database to both create and delete todo items.\\r\\n13. When a Mongoose schema is defined for the todos model, what happens?\\r\\na. A todos collection is created in the MongoDB database.\\r\\nb. The REST APIs are built in the MongoDB database.\\r\\nc. A todos collection is created in the Express web server.\\r\\nd. The REST APIs are created in the Express web server.\\r\\n14. What does the controller do?\\r\\na. The controller contains code that configures the MongoDB database and Mongoose.\\r\\nb. The controller contains code that builds the REST APIs.\\r\\nc. The controller contains code that creates the React components.\\r\\nd. The controller contains code that calls the Mongoose CRUD functions to interact with the\\r\\nMongoDB database.\\r\\n15. What is Postman?\\r\\na. the port that runs the Express web server\\r\\nb. an API platform testing tool\\r\\nc. the database connection URL to the Mongo DB database\\r\\nd. the connection that allows the CRUD functions to interact with the Express web server\\r\\n16. What is the purpose of Axios?\\r\\na. Axios runs the Express web server.\\r\\nb. Axios is used by the Node application to fetch data by making requests to a given endpoint.\\r\\nc. Axios runs the MongoDB database.\\r\\nd. Axios is used by the React application to fetch data by making requests to a given endpoint.\\r\\n17\\nCited Pages: 668, 669, 670\\n\\nSnippet 15:\\n serves as the front end handling the user interface to\\nget and set data via HTTP requests. Django serves as the back end.\\n• To build the Todo application using Bootstrap with React and Django, you need Python v3.9.4, PIP v21.3.1,\\nDjango v4.0.1, Django REST Framework v3.13.1, Bootstrap v4.5.0, Django-cors-headers v3.11.0, React\\nv17.0.2, and Axios v0.21.0.\\n• The React application uses Axios to fetch data by making requests to a given endpoint.\\n• A proxy to the Django application helps tunnel API requests from the React application to\\nhttp://localhost:8000, where the Django application will receive and handle the requests.\\n11.5Sample Native WAD with React Native and Node or Django\\n• A Todo application for mobile devices can be developed using React Native and Node.\\n• React Native is an open-source JavaScript framework used to build user interfaces and native applications\\nfor mobile devices.\\n• To build a Todo application for mobile devices, React Native serves as the front end handling the user\\ninterface and getting and setting data via HTTP requests. Node serves as the back end that makes use of\\nthe API built using the Django REST Framework in 11.2 Sample Responsive WAD with Bootstrap and\\nDjango.\\n• Building the Todo mobile application using React Native and Node requires React Native v0.67, Node\\nv14.17.5, ExpressJS v4.17.2, MongooseJS v6.1.9, and Axios v0.21.0.\\n11.6Sample Ethereum Blockchain Web 2.0/Web 3.0 Application\\n• A simple Todo application can be created using React with Web 3.0 powered by Ethereum smart contracts\\non the blockchain.\\n• The Ethereum blockchain creates a secure peer-to-peer network through the use of smart contracts, which\\nare secure digital agreements that enable users to transact directly with each other via the Web.\\n• Building the Todo Ethereum blockchain Web 3.0 application requires React v17.0.2, Bootstrap v4.5.0, Node\\nv14.17.5, Web 3.js v1.2.2, Truffle v5.0.2, Solidity v0.8.11, and Ganache.\\n• The Truffle Framework, which is a suite of tools popular to develop smart contracts, can be used to\\ndevelop the Ethereum smart contract.\\n• The Truffle Framework can be implemented using Solidity, which is a high-level, object-oriented language\\nthat is focused on the implementation of smart contracts.\\nReview Questions\\n1. What is MVC?\\na. the primary design pattern used for SPA applications\\n658 11 • Chapter Review\\nAccess for free at openstax.orgb. a software architecture pattern that separates a system’s presentation, business logic, and data\\nc. a software pattern for loose coupling and high cohesion\\nd. stands for Multi-Vector Chain, a principal technology used in Web 3.0 blockchain applications\\n2. What is a web application framework?\\na. software designed to aid in developing web applications\\nb. software that restricts the boundaries and edges of the network for the application\\nc. software that provides cybersecurity for web applications\\nd. software that increases the performance of a web application when networking traffic is heavy\\n3. What is a native application framework?\\na. software designed to support development and execution targeted toward a specific platform (e.g.,\\nAndroid, iOS)\\nb. program for writing assembly language for a given device\\nc. software tools created by a company that also creates the targeted device\\nd. software designed for responsive Web 2.0 SPA applications\\n4. List examples of web and native application frameworks.\\n5. Why is it difficult to implement server-side rendering using MVC?\\n6. What is a responsive web application?\\na. a web application that runs very quickly\\nb. the web application runs as an SPA\\nc. a web application that changes the look and feel based on the user’s credentials\\nd. a web application that is effective regardless of a user’s device constraints, such as screen size or\\norientation\\n7. What is jQuery?\\na. a web application framework like Angular\\nb. the official name for JavaScript\\nc. an open-source JavaScript library used for browser-based functionality\\nd. a Java-based implementation for server-side rendering\\n8. What is the difference between the first and current generations of web frameworks?\\na. The names were changed; however, they have no differences.\\nb. Current web frameworks require blockchain, while previous generations did not.\\nc. First-generation web frameworks only used HTML and CSS, while current versions use JavaScript.\\nd. Current generation web frameworks adhere to updated web standards and resolve issues with the\\ninitial implementations.\\n9. What are the differences between Web 2.0 and Web 3.0 applications?\\n10. What is Bootstrap?\\na. a Python-based web application development framework\\nb. a tool to control response outputs and convert complex data into content, such as JSON\\nc. an open-source, responsive web application framework\\nd. a high-level directory used to contain the directories and files necessary to run a Django web\\napplication\\n11. Using Bootstrap and Django, what should you do to define the Todo model?\\n11 • Chapter Review 659a. create serializers\\nb. use the default Django admin interface to perform CRUD operations on the database\\nc. enter category names and click the Post button\\nd. install Bootstrap\\n12. Why is the View function important?\\na. The View function enables users to create user interfaces.\\nb. The View function creates a Django project, which is needed to contain directories and files.\\nc. The View function is required to generate the todo/ directory.\\nd. The View function is needed to interact with the database to both create and delete todo items.\\n13. When a Mongoose schema is defined for the todos model, what happens?\\na. A todos collection is created in the MongoDB database.\\nb. The REST APIs are built in the MongoDB database.\\nc. A todos collection is created in the Express web server.\\nd. The REST APIs are created in the Express web server.\\n14. What does the controller do?\\na. The controller contains code that configures the MongoDB database and Mongoose.\\nb. The controller contains code that builds the REST APIs.\\nc. The controller contains code that creates the React components.\\nd. The controller contains code that calls the Mongoose CRUD functions to interact with the\\nMongoDB database.\\n15. What is Postman?\\na. the port that runs the Express web server\\nb. an API platform testing tool\\nc. the database connection URL to the Mongo DB database\\nd. the connection that allows the CRUD functions to interact with the Express web server\\n16. What is the purpose of Axios?\\na. Axios runs the Express web server.\\nb. Axios is used by the Node application to fetch data by making requests to a given endpoint.\\nc. Axios runs the MongoDB database.\\nd. Axios is used by the React application to fetch data by making requests to a given endpoint.\\n17. When using Bootstrap with React and Django to update t\\nCited Pages: 668, 669, 670\\n\\nSnippet 16:\\nthey\\r\\nrepresent the problem.\\r\\nGLOBAL ISSUES IN TECHNOLOGY\\r\\nContact Tracing\\r\\nEpidemiology is the study of how infectious diseases spread across the world. Within epidemiology, contact\\r\\ntracing attempts to identify confirmed cases of disease and limit its spread by tracing contacted people and\\r\\nisolating them from further spreading the disease.\\r\\nGraph data structures can help epidemiologists manage the data and people involved in contact tracing.\\r\\nImagine a graph where each vertex in a tracing graph represents a person, and each edge between two\\r\\npeople represents a possible contact. When a person receives a positive test result for contracting the\\r\\ndisease, healthcare professionals can identify all the people that they’ve been in contact with by tracing\\r\\nthrough the graph.\\r\\nIn addition to improving public health through contact tracing, our imaginary graph can also represent a\\r\\nhistory of the spread of the disease for epidemiologists to understand how the disease moves through\\r\\ncommunities. For example, if each vertex includes identity characteristic data such as age, race, or gender,\\r\\nepidemiologists can study which groups of people are most affected by the disease. This can then inform\\r\\nthe distribution of vaccines to assist the most impacted groups first.\\r\\n3.1 • Introduction to Data Structures and Algorithms 99Complex Data\\r\\nNow that we have seen several data structure implementations for abstract data, let us consider how these\\r\\ndata structures are used in practice. Recall that we compared calculators whose algorithms operated on\\r\\nnumbers with the idea of a computer whose algorithms operated on complex data. Data structures can be\\r\\nused to represent complex data by modeling hierarchy and relationships.\\r\\nWe might represent an online retail store as a map associating each item with details such as an image, a brief\\r\\ndescription, price, and the number of items in stock. This map makes some online storefront features easier to\\r\\nimplement than others. Given an item, this map makes it easy to retrieve the details associated with that item.\\r\\nOn the other hand, it is not so easy to sort items by price, sort items by popularity, or search for an item by\\r\\nkeywords in its description. All these features could be implemented with additional data structures. We can\\r\\ncombine multiple data structures together to implement these features. In computer science, we use database\\r\\nsystems (see Chapter 8 Data Management) that work behind the scenes in many applications to manage these\\r\\ndata structures and facilitate long-term storage and access to large amounts of data.\\r\\nJust as calculators have algorithms for calculating numbers, computers have algorithms for computing\\r\\ncomplex data. Data structures represent these complex data, and algorithms act on these data structures.\\r\\n3.2 Algorithm Design and Discovery\\r\\nLearning Objectives\\r\\nBy the end of this section, you will be able to:\\r\\n• Understand the approach to solving algorithmic problems\\r\\n• Explain how algorithm design patterns are used to solve new problems\\r\\n• Describe how algorithms are analyzed\\r\\nOur introduction to data structures focused primarily on representing complex data. But computer scientists\\r\\nare also interested in designing algorithms for solving a wider variety of problems beyond storing and\\r\\nretrieving data. For example, they may want to plan a route between a start location and an end location on a\\r\\nmap. Although every real-world problem is unique, computer scientists can use a general set of principles to\\r\\ndesign solutions without needing to develop new algorithms from scratch. Just like how many data structures\\r\\ncan represent the same abstract data type, many different solutions exist to solve the same problem.\\r\\nAlgorithmic Problem Solving\\r\\nAn algorithm is a sequence of precise instructions that takes any input and computes the corresponding\\r\\noutput, while algorithmic problem-solving refers to a particular set of approaches and methods for\\r\\ndesigning algorithms that draws on computing’s historical connections to the study of mathematical problem\\r\\nsolving. Early computer scientists were influenced by mathematical formalism and mathematical problem\\r\\nsolving. George Pólya’s 1945 book, How to Solve It, outlines a process for solving problems that begins with a\\r\\nformal understanding of the problem and ends with a solution to the problem. As an algorithm\\'s input size is\\r\\nalways finite, finding a solution to an algorithmic problem can always be accomplished by exhaustive search.\\r\\nTherefore, the goal of algorithmic problem-solving, as opposed to mathematical problem solving, is to find an\\r\\n“efficient” solution, either in terms of execution time (e.g., number of computer instructions) or space used\\r\\n(e.g., computer memory size). Consequently, the study of algorithmic problem-solving emphasizes the formal\\r\\nproblem or task, with specific input data and output data corresponding to each input. There are many other\\r\\nways to solve problems with computers, but this mathematical approach remains the dominant approach in\\r\\nthe field. Here are a few well-known problems in computer science that we will explore later in this chapter.\\r\\nA data structure problem is a computational problem involving the storage and retrieval of elements for\\r\\nimplementing abstract data types such as lists, sets, maps, and priority queues. These include:\\r\\n• searching, or the problem of retrieving a target element from a collection of elements\\r\\n100 3 • Data Structures and Algorithms\\r\\nAccess for free at openstax.org• sorting, or the problem of rearranging elements into a logical order\\r\\n• hashing, or the problem of assigning a meaningful integer index for each object\\r\\nA graph problem is a computational problem involving graphs that represent relationships between data.\\r\\nThese include:\\r\\n• traversal, or the problem of exploring all the vertices in a graph\\r\\n• minimum spanning tree is the problem of finding a lowest-cost way to connect all the vertices to each\\r\\nother\\r\\n• shortest path is the problem of finding the lowest-cost way to get from one vertex to another\\r\\nA string problem is a computational problem involving text or information represented as a sequence of\\r\\ncharacters. Examples include:\\r\\n• matching, or the problem of searching for a text pattern within a document\\r\\n• compression, or the problem of representing information using less data storage\\r\\n• cryptography, or the problem of masking or obfuscating text to make it unintelligible\\r\\nModeling\\r\\nComputer scientists focus on defining a problem model, often simply called a model, which is a simplified,\\r\\nabstract representation of more complex real-world problems. They apply the algorithmic problem-solving\\r\\nprocess mentioned previously to design algorithms when defining models. Algorithms model phenom\\nCited Pages: 109, 110, 111']\n",
            "\n",
            "=== Grade ===\n",
            "Pass\n",
            "\n",
            "=== Feedback ===\n",
            "['The study guide meets all the required criteria for a Pass. It draws from at least five distinct sections of the book: pages 23-25 (how computers work, including hardware, software, and computation principles), 85-87 (web and native app development frameworks and architectures), 585-587 (modern web application architectures, Web 2.0/3.0, and frameworks), 668-670 (practical web app development with frameworks and tools), and 109-111 (algorithms, data structures, and complexity). Each concept in the guide is directly supported by the cited textbook content, and the guide does not introduce any information not found in the book. The roadmap is clear, with each major topic (computers, web app development, algorithms) covered by multiple relevant sections, ensuring a comprehensive learning path. No hallucinations or irrelevant content are present. Well-structured and contextually accurate.']\n",
            "\n",
            "=== Number of Iterations ===\n",
            "1\n"
          ]
        }
      ],
      "source": [
        "\n",
        "from langchain_core.messages import HumanMessage\n",
        "\n",
        "triple_request = \"I want to understand how computers work, I want to learn about web app development, and also algorithms. Make me a detailed guide for all three.\"\n",
        "\n",
        "\n",
        "msg = HumanMessage(content=triple_request)\n",
        "state = graph.invoke({\"messages\": [msg]})\n",
        "\n",
        "# Pretty Print entire state. Get snapshot of output.\n",
        "\n",
        "print(\"Final output:\")\n",
        "\n",
        "print(\"\\n=== Original Query ===\")\n",
        "print(state.get(\"original_query\", \"No original query found.\"))\n",
        "\n",
        "print(\"\\n=== Study Guide ===\")\n",
        "resulting_study_guide = state.get(\"study_guide\", \"\")\n",
        "\n",
        "for sg in resulting_study_guide.study_guide:\n",
        "    print(f\"\\n=== Study Guide ===\")\n",
        "    print(sg)\n",
        "\n",
        "\n",
        "print(\"\\n=== Retrieved Context ===\")\n",
        "print(state.get(\"retrieved_context\", \"No context retrieved.\"))\n",
        "\n",
        "print(\"\\n=== Grade ===\")\n",
        "print(state.get(\"grade\", \"No grade assigned.\"))\n",
        "\n",
        "print(\"\\n=== Feedback ===\")\n",
        "print(state.get(\"feedback\", \"No feedback provided.\"))\n",
        "\n",
        "print(\"\\n=== Number of Iterations ===\")\n",
        "print(state.get(\"num_iterations\", \"No iterations counted.\"))\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Cleaning up\n",
        "\n",
        "Congrats! You've build a simple agentic application using Pinecone Assistant, LangGraph and OpenAI.\n",
        "\n",
        "Now, try to extend the example:\n",
        "\n",
        "- alter the Context API tool and node to do multiple, parallel tool calls\n",
        "- add in a human in the loop feature to have a human provide feedback to the final copy\n",
        "- add more pdfs to do a broader search\n",
        "\n",
        "To clean up, we'll delete our assistant. Please make sure only to do this if you are ready!"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "pc.assistant.delete_assistant(\n",
        "    assistant_name=\"textbook-assistant\", \n",
        ")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": []
    }
  ],
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "display_name": "pinecone-examples",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.11.9"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 4
}
